当我不在我的代码中调用相同的函数时,一切正常,但是当函数从递归突然返回时,变量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, ",");
}
}
因此,例如,当循环作用于字符串file2,file3,file4
时,它会正确拆分file2
并将字符串修改为,file2\\000file3,file4
但下一次调用pch = strtok (NULL, ",");
呈现pch
为0x0
。调用递归时有什么我不知道的吗?