#include<iostream>
#include<string.h>
using namespace std;
int main ()
{
char sentence []= "this is a sentence with 7 tokens";
cout <<"this string to be tokenized is "<<endl<<sentence<<endl;
char *tokenp=strtok(sentence," ");
while (tokenp)
{
cout <<tokenp<<endl;
tokenp=strtok(NULL," ");
//cout <<sentence<<endl;
}
cout <<"after strtok sentence ="<<sentence<<endl;
return 0;
}
strtok--字符串处理
最新推荐文章于 2024-09-09 11:53:04 发布