我必须将.in文件输入我的program.gcc ./" file" < file.in
因为有多个输入我必须使用While循环EOF,但是
因为我不能再扫描一次。
这是我的程序的模拟版本。谢谢
#include <stdio.h>
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);
}
答案 0 :(得分:1)
试试这个
freopen("con:", "r", stdin);//this for windows. "/dev/tty" for *nix ?
scanf("%d", &num);