首页 > 其他 > 详细

输出分割的字符串

时间:2020-03-30 19:59:40      阅读:67      评论:0      收藏:0      [点我收藏+]
 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[] = "\n\f\v\t";
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\n", result);
24         result = strtok(NULL, delims);
25     }
26     system("pause");
27 
28 }

 

输出分割的字符串

原文:https://www.cnblogs.com/lianggaoblogyuan/p/12600470.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!