c - strtok 函数 const char 指针错误
问题描述
我不断收到以下错误
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
解决方案
strtok
需要对您的字符串进行更改,因此它不能对const char*
参数进行操作。您需要先复制该字符串,然后再将其发送到strtok
.
推荐阅读
- profiling - 本机代码中的高 CPU 使用率
- javascript - 媒体元素播放器不工作
- angular - Angular 5 不检查多个条件
- python - XL_CHART_TYPE.DOUGNHUT 设置孔尺寸
- php - Woocommerce 产品提要默认定价问题
- android - 片段不保留数据
- javascript - 如何将 Blob 元素从 javascript 传递到 oracle 顶点项?
- ios - 在 swift iOS 中从 tableview 中选择时 UIsearchbar 结果出错
- django - html2pdf 与 Django
- java - 如何仅删除奥利奥及更高版本的小部件?