如何在使用while loop scanf!= EOF后使用scanf

我必须在我的program.gcc ./”file“<file.in中输入一个.in文件
因为有多个输入我必须使用While循环EOF,但因为我不能再扫描。 这是我的程序的模拟版本。 谢谢

#include  int main() { int arr[100]; int num; int count = 0; while( scanf("%d", &arr[count]) != EOF ) { count++; } printf("%d\n", arr[0]); scanf("%d", &num); printf("%d\n", num); } 

试试这个

 freopen("con:", "r", stdin);//this for windows. "/dev/tty" for *nix ? scanf("%d", &num);