0

I read somewhere that while(fgets(line, sizeof(line), stdin) != NULL) should read from standard input until you press Ctrl+D which represents EOF and generates NULL, but my program keeps going even though I press Ctrl+D, anyone have any ideas? everything is appreciated.

Iharob Al Asimi
  • 52,066
  • 5
  • 58
  • 95
Frans
  • 79
  • 2
  • 10

1 Answers1

1

Ctrl+D is not defined as EOF in the C language specification. Ctrl+D is defined at the operating system level. Therefore, you must be on a system on which Ctrl+D has not the behaviour you expect.

Iharob Al Asimi
  • 52,066
  • 5
  • 58
  • 95
Alexandre Fenyo
  • 4,030
  • 1
  • 12
  • 23
  • thanks! I tried on Linux instead of Windows and now it works as it should! IT was meant to work in Linux so that's what matters anyways! – Frans Sep 04 '17 at 17:49