fscanf()问题
int getsth(FILE* & filein, int &obj1, char &obj2){ if(fscanf(filein,"%d",&obj1) == 1) { printf("%d\n",obj1); return 1; } if(fscanf(filein,"%c",&obj2) == 1) { if(obj2 == ' ') { printf("空格\n"); return getsth(filein, obj1, obj2); } else { printf("%c\n",obj2); return 2; } }}int main(){ FILE *fp = fopen("data.txt", "r"); int obj1 = 0; char obj2 = '\0'; int state = getsth(fp, obj1, obj2); while(state == 1 ||(state == 2 && obj2 != '\n')) { if(state == 1) { state = getsth(fp, obj1, obj2); } else { break; } } return 0;}