1、该函数参数是char ,所以就算传入一个const char ,也会被修改。
2、替代函数
#include <stdio.h>
#include <string.h>
int main() {
const char *str = "Hello, world! How are you?";
char *copy = strdup(str);
char *token = strsep(©, " ");
while (token != NULL) {
printf("%s\n", token);
token = strsep(©, " ");
}
printf("--------------\n%s\n",str);
return 0;
}
注意只支持gnuc,windows下的mingw c不支持的。