【发布时间】:2012-01-29 01:37:02
【问题描述】:
我正在使用strtok 并且有点困惑。
我有一个包含很多字符串的数组,我想将这些字符串标记为一个临时数组。当我执行 strtok 时,它将第一个令牌存储在临时数组中,但也更改了原始数组值。所以我很困惑。
char cmdTok[10] , *cmd = cmdTok;
printf("command[0] = %s\n", commands[0]);
cmd = strtok(commands[0], " \n\0");
printf("command[0] after strtok = %s\n", commands[0]);
输出存在
command[0] = #Draw A Ring
command[0] after strtok = #draw
如何在命令中保留原始值?
【问题讨论】: