-1
int
read_data(void){
char type;
double x_val,y_val,noise_val;
while (scanf("%c %lf %lf %lf",&type,&x_val,&y_val,&noise_val)==4){
printf("%c %lf %lf %lf",type,x_val,y_val,noise_val);
}
return 0;
}
輸入是
N 501.0 7501.0 80.0
N 1001.0 5001.0 90.0
N 3501.0 7501.0 130.0
N 5001.0 2001.0 85.0
當我編譯爲test < testing.txt
只打印第一行後進入。
但是,如果我刪除while循環,並繼續添加更多的scanfs和打印這是輸出。
N 501.000000 7501.000000 80.000000
501.000000 7501.000000 80.000000
N 1001.000000 5001.000000 90.000000
1001.000000 5001.000000 90.000000
N 3501.000000 7501.000000 130.000000
3501.000000 7501.000000 130.000000
N 5001.000000 2001.000000 85.000000
5001.000000 2001.000000 85.000000
怎麼回事?