Tom*_*Tom 6 c recursion strtok
当我没有在我的代码中调用相同的函数时,一切都运行良好,但是当函数突然从递归返回时,变量pch
为NULL:
void someFunction()
{
char * pch;
char tempDependencies[100*64+100];
strcpy(tempDependencies,map[j].filesNeeded);
pch = strtok(tempDependencies,",");
while (pch != NULL)
{
someFunction(); <- if i comment this out it works fine
pch = strtok (NULL, ",");
}
}
Run Code Online (Sandbox Code Playgroud)
因此,例如当循环作用于字符串时,file2,file3,file4
它正确地拆分file2
并修改字符串,file2\\000file3,file4
但下一次调用pch = strtok (NULL, ",");
渲染pch
为0x0
.在调用递归时是否有我不知道的事情?