嘿,我正在尝试使用C中的strtok函数,并使用“”作为分隔符,但由于某些原因,它不起作用。有人能告诉我如何使用strtok以空格为分隔符进行解析吗?
发布于 2010-11-12 07:29:30
从here窃取(略微修改)。
/* strtok example */
#include <stdio.h>
#include <string.h>
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;
}发布于 2011-11-14 08:57:00
使用制表符"\t“或同时使用”\t“,即。空格键和制表符both...see (如果有效
https://stackoverflow.com/questions/4160273
复制相似问题