C++可以用指針數組從字符串中提取子字符串麼?
如果可以請給一個示范QAQ
http://www.cnblogs.com/xiangzi888/archive/2012/04/16/2451947.html
/* strtok example */
#include <stdio.h>
#include <string.h>
int main (void)
{
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, " ,.-");
}
printf("at the end: %s", str);
return 0;
}