积极答复者
strtok报错

问题
答案
-
char *str1="I am very happy,nprogramme";
修改为char str1[] = "I am very happy,nprogramme";
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已标记为答案 Honny_yeyh 2011年2月14日 4:43
-
Hi Hoony,
按VsualEleven的建议去改,应该是会解决您的问题的。
这是因为strtok()本身原因,这个函数会将被切割函数中出现切割字符的位置改写为'\0'。也就是函数本身会去改写它的第一参数
而
char *p=“aaaaaaaa”; //这样定义的字符串被存放在文字常量区,也就是字符串本身是一个常量,一般情况下不允许修改
char a[]=“aaaaaaaa”; //这种情况下字符串在栈区,可以修改如果您的问题解决了,请把有用的回答标记为答案,
谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Honny_yeyh 2011年2月14日 4:43
全部回复
-
char *str1="I am very happy,nprogramme";
修改为char str1[] = "I am very happy,nprogramme";
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已标记为答案 Honny_yeyh 2011年2月14日 4:43
-
Hi Hoony,
按VsualEleven的建议去改,应该是会解决您的问题的。
这是因为strtok()本身原因,这个函数会将被切割函数中出现切割字符的位置改写为'\0'。也就是函数本身会去改写它的第一参数
而
char *p=“aaaaaaaa”; //这样定义的字符串被存放在文字常量区,也就是字符串本身是一个常量,一般情况下不允许修改
char a[]=“aaaaaaaa”; //这种情况下字符串在栈区,可以修改如果您的问题解决了,请把有用的回答标记为答案,
谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Honny_yeyh 2011年2月14日 4:43