I am trying to write a C program that takes n
as an integer input and then inputs n
strings. The problem that when I run the program, it takes one input less than n
. If I enter 1
as the first input the program just terminates. Here is the code :
int n;
scanf("%d", &n);
char str[101];
while (n--) {
fgets(str, 101, stdin);
// other stuff...
}
What am I doing wrong here?