I'm supposed to write a simple C program to read in an integer and loop n times to work on the string, but the first loop automatically passes an empty string if I use the scanf integer, but if I use a constant number the loop works right. Somebody please explain to me what's going on.
#include <stdio.h>
#define MAX 80
int main(){
char sentence[MAX];
int n, i;
scanf("%d", &n);
for(i=0; i<3; i++){//it loops with empty string automatically if I replace 3 with n
gets(sentence);
printf("%s\n", sentence);
}
}