#include <iostream>
#include <cstring>
using namespace std;
int main(){
char sentence[]="This is a sentence with 7 tokens";
cout<<"The string to be tokenized is:\n"<<sentence<<"\n\nThe tokens are:\n\n";
char *tokenPtr=strtok(sentence," ");
while(tokenPtr!=NULL){
cout<<tokenPtr<<'\n';
tokenPtr=strtok(NULL," ");
}
//cout<<"After strtok, sentence = "<<tokenPtr<<endl;
return 0;
}
strtok的用法
最新推荐文章于 2022-09-12 10:47:00 发布