0

Make code looks like this:

  #include <stdio.h>

  /*Program 1*/
  int main(void) {
      int c;

      while ((c = getchar()) != EOF) {
          putchar(c);
      }

      return 0;
  }

I was trying to figure out why is that for the input:

aa CTRL+D //=> aa

And for the input:

CTRL+D //=> The program properly ends.

Why in the first example EOF doesn't cause the program to exit.

Adrian Baran
  • 885
  • 7
  • 23

0 Answers0