My program is using while scanf != EOF to input standard inputs from a .in file. as in ./"file" < file.in The problem is that I have to scanf from the terminal after that. Is there a way I can invoke EOF to the stdin so that the file stops scanning from file.in or maybe specify scanf to read from the terminal and not the file. I'm also only allowed to use scanf as this is a college assignment. This is a mock program of my issue. Thanks
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);
}
** Output is just the number of the first list of number, and scanf is completely ignored with no value in print num.
ctrl-din linux,ctrl-zin windows - clctowhiledoesn't do what you expect. - edmz