简体   繁体   中英

strtok function const char pointer error

I keep getting the following Error

passing argument 1 of 'strtok' discards 'const' qualifier from pointer target type [enabled by default]

Through this line

for (char *p = strtok(season_info,"\n"); p != NULL; p = strtok(NULL, " "))

ps: season_info is defined like this: const char* season_info

strtok needs to make changes to your string, so it can't operate on a const char* argument. You'll need to make a copy of that string before sending it to strtok .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM