输出分割的字符串
Posted lianggaoblogyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输出分割的字符串相关的知识,希望对你有一定的参考价值。
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 }
以上是关于输出分割的字符串的主要内容,如果未能解决你的问题,请参考以下文章