I've already read the FAQ entery wich is located here so please don't mention it and focus on answering my question.
Code:
#include<stdio.h>
int main()
{
int number;
char ch , string[100];
printf("Input a number : \n");
scanf("%d", &number);
while( ch = getchar() != '\n' && ch != EOF);
printf("Input a string : \n");
fgets(string, sizeof(string), stdin);
printf("You've entered %d and %s\n", number , string);
return 0;
}
now my questions are :
[list=1][*]Why doesn't the program wait for the user to input a character with getchar() in the line :
while( ch = getchar() != '\n' && ch != EOF);
[*] I've read on some sites that scanf() leaves the '\n' on the input buffer. If thats right , then why doesn't fgets() leaves one too??
[*]why doesn't fgets() wait for input if the '\n' was in stdin??[/list=1]
thanks for your time.