(Walter Roberson) writes:
> In article <>,
> Keith Thompson <kst-> wrote:
>> (Walter Roberson) writes:
>>> In article <. com>,
>>> FUGATO <> wrote:
>
>>>> printf("Enter the filename to be scanned: "); // ask the user
>
>>> Minus 1 point for not ending the prompt with '\n' and another for
>>> not using fflush() to ensure that the prompt will be displayed before the
>>> read.
>
>>With a call to fflush(stdout) after the printf(), a newline is not
>>necessary.
>
> For text files, the status of the last line is officially indeterminate
> if there is no newline at the end of the line. fflush() does not
> introduce that newline: it just spills the accumulated buffer.
> Hence to be -sure- that prompt will be visible, you must terminate
> it with a newline.
Only if it's the last line of output.
>>(In fact, I prefer not to have a newline at the end of a
>>prompt; it makes things clearer to the user.)
>
> Yeah, but it relies upon system-specific behaviour.
>
> Though this discussion does lead to the question of whether
> stdout is a text stream or a binary stream ?
It's a text stream.
C99 7.19.1p3:
stderr
stdin
stdout
which are expressions of type "pointer to FILE" that point to the
FILE objects associated, respectively, with the standard error,
input, and output streams.
C99 7.19.3p7:
At program startup, three text streams are predefined and need not
be opened explicitly -- _standard input_ (for reading conventional
input), _standard output_ (for writing conventional output), and
_standard error_ (for writing diagnostic output). As initially
opened, the standard error stream is not fully buffered; the
standard input and standard output streams are fully buffered if
and only if the stream can be determined not to refer to an
interactive device.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.