1 #pragma warning(disable:4996) 2 #include<stdio.h> 3 #include<string.h> 4 #include<stdlib.h> 5 int main() { 6 7 FILE*p = fopen("Text.txt", "r+"); 8 if (p != NULL) { 9 printf_s("%s", "open success"); 10 } 11 else { 12 printf_s("%s", "open fail"); 13 14 } 15 char buf[20]; 16 fgets(buf, 19, p); 17 char sep[] = " fv "; 18 char str[] = "now # is the time for all # good men to come to the # aid of their country $ while you $ are a student"; 19 char delims[] = "#$";//这里如果以#和空格分开,则delims[]="# "; 20 char*result = NULL; 21 result=strtok(str, delims); 22 while (result != NULL) { 23 printf_s("%s ", result); 24 result = strtok(NULL, delims); 25 } 26 system("pause"); 27 28 }