#include <stdio.h>
#include <string.h>
int main(void) {
char string[10000],*token;
int garden[100],i=0;
fgets(string,10000,stdin);
token = strtok(string," ");
while(strcmp(token,"\n") != 0){
garden[i] = atoi(token);
i++;
token = strtok(NULL," ");
}
return 0;
}
此代碼有什麼問題?爲什麼我不能從一行讀取空格分隔的整數?C fgets strtok和atoi在C中讀取一行
如果未找到標記'strtok'返回空指針。 – user1336087 2014-10-04 08:42:23