我有我的代码有问题,我不断收到编译器错误:C语言的strtok有一些错误
error message : warning: assignment makes pointer from integer without a cast
我的代码很简单:
int i;
int arr1[8], arr2[8];
char test[] = "1|a|b;2|c|d;3|e|f";
char *split1, *split2;
split1 = strtok(test, ";");
for(i = 1; i <= 8; i++){
arr1[i] = split1;
split1 = strtok(NULL, ";");
printf("result=%s\n", arr1[i]);
}
当我修复编译器错误,我的代码无法打印价值,反之亦然!
'arr [8]'不存在;你不要使用'arr [0]' – pmg
将arr1改为char * – cup
为什么要将指向字符串的指针放入整数数组中? – AntonH