After printing "Second text", fgets
expect from me to enter a string but a program is always being stopped. That happens when I try to enter a char by scanf
or getchar
. What's happening?
#include <stdio.h>
int main()
{
char c[100],cc;
int x;
printf("First text\n");
scanf("%d",&x);
printf("Second text\n");
fgets(c,100,stdin);
//scanf("%c",&cc);
//cc=getchar();
printf("\n %s %d",c,x);
}