您的位置:首页 > 其它

strtok CString 分割字符串

2012-11-06 11:48 323 查看
#include

#include

int main ()

{

char str[] ="- This, a sample string.";

char * pch;

printf ("Splitting string \"%s\" into tokens:\n",str);

pch = strtok (str," ,.-");

while (pch != NULL)

{

printf ("%s\n",pch);

pch = strtok (NULL, " ,.-");

}

return 0;

}

函数执行的结果:

Splitting string "- This, a sample string." into tokens:
This
a
sample
string
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: