I know this is very old. I'm new to c and wanted to check my method, which uses getchar
:
#include
int main()
{
printf("Please enter your name\n");
char string[10];
scanf("%s", string);
printf("Hello %s\n", string);
//getchar(); # un commenting this line, fgets perfectly works!!
printf("Please enter your name again\n");
fgets ( string, 10, stdin );
printf("Hello again %s", string);
getchar();
}