這個scanf應該總是返回true,直到我輸入沒有數字輸入,但是這個scanf從不執行while循環。爲什麼?爲什麼這個scanf返回false?
樣品輸入:
10.0 5.0
Press [Enter] to close the terminal ...
代碼:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
float a, b;
while (scanf("%f %f", &a, &b) == 1)
{
printf("%f\n", (a - b)/(a * b));
}
return (EXIT_SUCCESS);
}
THX,理解 – gameboy 2010-10-13 12:41:05