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

sstrtok函数用法

时间:2020-06-07 19:23:05      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:存储   数组   读取   har   cstring   pre   while   cin   字符   

 1 #include <iostream>
 2 #include <cstring>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     string s;
 9     getline(cin,s);    // 读取一行
10     char *p;    // 存储分割完一次分出的字符数组
11     char *ss = const_cast<char *>(s.c_str() );
12     p = strtok(ss," ");
13     while(p)
14     {
15         cout << p << "----";
16         p = strtok(NULL," ");
17     }
18     cout << endl << s << endl << ss << endl;
19     return 0;
20 }

 

sstrtok函数用法

标签:存储   数组   读取   har   cstring   pre   while   cin   字符   

原文地址:https://www.cnblogs.com/limancx/p/13061482.html

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