Hi all,
I have two doubts relating to the following code.
Code:
#include <stdio.h>
int main(void)
{
int i;
char c;
printf("Enter some integer value:");
scanf("%d",&i);
__fpurge(stdin);
printf("Enter some character:");
scanf("%c",&c);
printf("Input values are %d and %c\n",i,c);
return 0;
}
1. In the above code if i remove the fpurge() function then i am not able to input the character (i.e.,) the scanf() for getting the character got skipped
2. When i look into the man page for fpurge() it states that this function is not a standard one and also not portable, so i thought i can use fflush(stdin) but when i used fflush instead of fpurge the code works the same way i discussed in first step.
Why is this behaviour happening?