| Platform | End-of-line indicator | |
|---|---|---|
| Unix | an ASCII newline (\n) LF (linefeed) character | |
| Macintosh | an ASCII CR (\r) (carriage return) character | |
| Windows | an ASCII sequence CR LF (\r\n) |
This is certainly true when the input is coming from a file. However, if input is coming from stdin and if stdin is coming from the console keyboard then it should not be opened in binary mode, because that has the side effect of switching stdin into raw mode in which all characters are read one by one with no echo, and Ctrl-C and Ctrl-Z are disabled so you cannot signal EOF.
if (filename == "") {
fp = stdin;
#ifdef DJGPP
if (isatty( fileno(stdin) ) == 0)
setmode(fileno(stdin), O_BINARY);
#endif
}
else
fp = fopen( filename, "rb");
if (fp == NULL) {
fprintf(stderr,"Cannot open file %s\n", filename);
return(0);
}