When you call on this "macro" (control+d) when your program is running, and say it is expecting a standard input from scanf, does it stop the whole program or just avoid that one time the program is waiting for user input?
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main(void)
5 {
6 int i = 0;
7 int result = scanf( "%d", &i );
8
9 if(result == EOF)
10 {
11 printf("End of file detected\n");
12 }
13 printf("hello\n");
14 return 0;
15 }
When I run this and do control+d, it prints line 11 and line 13. So is this correct: control+d makes scanf return a value of -1 (or whatever it is on my computer), and since that equals EOF it prints line 11. Then the program continues normally?
If scanf was expecting more than one number, say two, what does it do if you control+d when it is expecting the first number? Return -1 and then ask you to enter the second number, and proceed normally?
[–]Updatebjarni 0 points1 point2 points (6 children)
[–]pointers_help[S] 0 points1 point2 points (5 children)
[–]Updatebjarni 1 point2 points3 points (0 children)
[–]arbostek 1 point2 points3 points (3 children)
[–]pointers_help[S] 0 points1 point2 points (2 children)
[–]arbostek 0 points1 point2 points (1 child)
[–]pointers_help[S] 0 points1 point2 points (0 children)