E
E_Dn
Guest
Hi....
I'm code blocks user.
Actually I'm learning it.
Then.. I'm in trouble in using fflush().
It doesn't work.
In C programing book," fflush(stdin); " deletes buffer...
So I wrote the code like this.
Result...
Write age : 19
Write name : 19 //this is automatically Written...
...End...
I'm code blocks user.
Actually I'm learning it.
Then.. I'm in trouble in using fflush().
It doesn't work.
In C programing book," fflush(stdin); " deletes buffer...
So I wrote the code like this.
Code:
#include<stdio.h>
int main(void)
{
int age;
char name[20];
printf("Write age : ");
scanf("%d", &age);
fflush(stdin);
printf("Write name : ");
fgets(name, sizeof(name), stdin);
printf("%d \n", age);
printf("%s \n", name);
return 0;
}
Result...
Write age : 19
Write name : 19 //this is automatically Written...
...End...