我需要将 tmp 的内容保存到 tmp2。但是 tmp 在 while 循环之外始终为 NULL。
if(1){
char* tmp;
char* tmp2;
// split the string on the space character
tmp = strtok(actual_args[0], " ");
while(tmp != NULL){
strcpy(tmp2, tmp);
tmp = strtok(NULL, " ");
}
// always NULL
printf("%s", tmp);
// produces seg. fault
printf("%s", tmp2);
}