Haven't touched C in a while. I don't remember having issues with fgets() but right now, I have this:




int age;
char name[50];

printf("Enter your name\n");
fgets(name, 50, stdin);
scanf("%d", &age);



When prompted for my name, I enter "test" without quotation marks obviously. When I press enter, the terminal just goes down a line... Over and over and over and it never stops and progresses past this point.

I remember having this issue sometimes with scanf and being able to use getchar() after or specify a "%s\n" in the call but not with fgets...

This is on MacOS High Sierra and I'm using gcc-8. What have I forgotten? Thanks.