我一直收到以下错误
passing argument 1 of 'strtok' discards 'const' qualifier from pointer target type [enabled by default]
通过这一行
for (char *p = strtok(season_info,"\n"); p != NULL; p = strtok(NULL, " "))
ps:season_info的定义如下: const char * season_info
答案 0 :(得分:1)
strtok
需要对字符串进行更改,因此无法对const char*
参数进行操作。在将该字符串发送到strtok
之前,您需要复制该字符串。