J
Jordan Abel
No, it doesn't handle EOF. However, if you have flushln available
you can write:
#define flushstdin flushln(stdin)
I've never heard of flushln - what systems does it exist on?
No, it doesn't handle EOF. However, if you have flushln available
you can write:
#define flushstdin flushln(stdin)
Jordan Abel said:I've never heard of flushln - what systems does it exist on?
Jordan said:I've never heard of flushln - what systems does it exist on?
Chuck F. said:All you had to do was read this thread. I have published at least two
realizations of flushln in it.
All you had to do was read this thread. I have published at least
two realizations of flushln in it.
He's even more careless than that. One of the flushlnRichard said:Chuck F. said:
Usenet is an asynchronous medium. Please don't assume that
everybody has been able to read all previous articles in a
thread. It is generally easy to skip around this problem; for
example, you could have said:
"However, if you use flushln() available on your system (source
for the fflushln function is provided upthread) you can
write..."
thanks.
but what I want to know is the "actual" reason,
not a "logical" one.
e.g.
void f( int*p )
{
if (p->num)
do something;
}
when this function is running, there will be an error.
if I don't know the reason,what I want to know is :
if p is a NULL pointer, p->num will cause the error.
so ,the fflush function works very well on my computer now,
If it cause a potential danger,
I want to know what is it, and what is the condition.
if possible, an example is the best.
I think I've already known the answer.
the below is I copied from MSDN:
The fflush function flushes a stream. If the file associated with
stream is open for output, fflush writes to that file the contents of
the buffer associated with the stream.
If the stream is open for input, fflush clears the contents of the
buffer.
#include <stdio.h>
#include <conio.h>
int main( void )
{
int integer;
char string[81];
/* Read each word as a string. */
printf( "Enter a sentence of four words with scanf: " );
for( integer = 0; integer < 4; integer++ )
{
scanf( "%s", string );
// Security caution!
// Beware allowing user to enter data directly into a buffer
// without checking for buffer overrun possiblity.
printf( "%s\n", string );
}
/* You must flush the input buffer before using gets. */
fflush( stdin ); // fflush on input stream is an extension to the
C standard
printf( "Enter the same sentence with gets: " );
gets( string );
printf( "%s\n", string );
}
then I know,I shouldn't use fflush(stdin) except in VC.
but in VC, it is safe.
He's even more careless than that. One of the flushln
implementations was quoted in the article to which he replied, and
he snipped it! So there is no doubt he saw it.
Maybe he is one of the Wikipedia editors who are amusing you?
(in article said:I've never heard of flushln - what systems does it exist on?
One of the flushln
implementations was quoted in the article to which he replied, and
he snipped it! So there is no doubt he saw it.
Maybe he is one of the Wikipedia editors who are amusing you?
Jordan Abel said:[snip]
I didn't bother reading all the quoted text, and the text i did read
[and quote] said nothing to imply that it was a function you had written
in an earlier message - "if ___ is available on your system" implies (to
me) that it's a non-universally-available extension.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.