I am trying to run somebody’s code and I am new to c so I have a problem with reading the input. The following loop read it from the keyboard, but when I am finished it doesn’t stop
while (fgets(in_line, MAXLINE, stdin) != NULL ) {
...
}
Is there any kind of character that I have to enter to simulate ‘NULL’? I’ve tried \0 but that doesn’t seem to work.
I am very sorry, this problem has probably arisen tons of times, but I just cannot find a proper explanation.
You get a NULL from
fgetswhen it reaches EOF. From the keyboard, that’s suually signalled with CTRL-Z (DOS/Windows and I think MacOS before X) or CTRL-D (Linux/Unix/MacOS X).