[英]Can a delim be used more than once for strtok in C?
Is there a way to use a delim more then once for strtok? 有没有一种方法可以使用delim然后再一次使用strtok? I can only get the code to work for either load or init but not both.
我只能使代码可用于加载或初始化,但不能同时用于两者。 Example code in which strtok is used to token input from the user in the form of load # or init #,#,direction:
示例代码,其中strtok用于标记用户以load#或init#,#,direction的形式输入的代码:
if ((tok = strtok(choice, " ")) && strcmp(tok, COMMAND_LOAD) == 0){
tok = NULL;
if((tok = strtok(tok, " ")) != NULL){
/*some code*/
}
}
else if((tok = strtok(choice, " ")) && strcmp(tok, COMMAND_INIT) == 0){
tok = NULL;
if((tok = strtok(tok, ",")) != NULL){
/*some code*/
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.