This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fflush(stdin)


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]