I’m trying to write a code which stores some strings in an array with fgets, but it doesn’t let me input the string of index 0 of the array. Can someone help me?
#include <stdio.h>
#include <stdlib.h>
int main(){
int lenght;
int i;
printf("Enter the lenght: ");
scanf("%d", &lenght);
char array[lenght][20];
for(i=0; i<lenght; i++)
{
printf("Enter the %d string: ", i);
fgets(array[i], 30, stdin);
}
for(i=0; i<lenght; i++)
{
printf("%s ", array[i]);
}
return 0;
}