Re: fflush(stdin)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

As the manpage of fflush() describes, fflush is only valid for output and update streams, thus the behavior on input is undefined. By definition it is pretty much pointless to flush an input stream/buffer anyway.

Reagrds

-Sven


Kolpur Srinivasa Chary schrieb:
Hi,
I am using gcc on Debian GNU/Linux, here is a program I wrote,

#include<stdio.h>
int main()
{
int d;
char a;
scanf("%d",&d);
fflush(stdin);
scanf("%c",&a);
printf("%d%c",d,a);
return 0;
}

But, fflush(stdin) was not as it should, it was not clearing buffer, so
I was not able to read the character input from the user.
So, is there any way to flush the buffer and read the character input
from the user? Please help me out.

Regards,
cnu


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux