字符串分割函数strtok例子

来源:互联网 发布:免费手机短信恢复软件 编辑:程序博客网 时间:2024/04/29 14:20
#include <iostream>#include <cstring>#include <map>using namespace std;int main(){char sentence[] = "this is a sectence with 7 tokens";char *tokerPtr = strtok(sentence," ");while(tokerPtr != NULL){cout<<tokerPtr <<endl;tokerPtr = strtok(NULL," ");}cout<<"sentence=="<<sentence<<endl;system("pause");return 0;}