码迷,mamicode.com
首页 > 其他好文 > 详细

输出分割的字符串

时间:2020-03-30 19:59:48      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:for   int   lims   null   har   pause   open   class   ble   

 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 }

 

输出分割的字符串

标签:for   int   lims   null   har   pause   open   class   ble   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!