Reputation: 73
I have to input a .in file into my program.gcc ./"file" < file.in
Because there are more than one input I have to use the While loop EOF, but
because of that I can't scanf again.
Here's a mock version of my program. Thank you
#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);
}
Upvotes: 2
Views: 863
Reputation: 40145
try this
freopen("con:", "r", stdin);//this for windows. "/dev/tty" for *nix ?
scanf("%d", &num);
Upvotes: 1