Does stdin have any EOF? For example, if I start reading from stdin using fread or read, then will the following loop end?
while ((c = read(0, buffer, BUFSIZ)) > 0) {
.
.
.
}
If the answer to this question is no, then is there any way to add EOF to stdin?
Speaking about
EOFin stdin: when you redirect input from file, e.g.:the file already has an
EOF, so this is not a problem. In console you can simulateEOFflag. In UNIX systems it is Ctrl+D, in Windows Ctrl+Z. When you type this in the console, program will behave like it has just reached end of input file.Edit
According to a question asked by OP:
Actually — yes. One may consider stdin (not redirected, but taken from the console) as infinite file — no one can tell where does it end. The end of input file, where input ist stdin, must be told literally by Ctrl+D or Ctrl+Z.