#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int count;
scanf("%d",&count);
char **array;
array = (char **) malloc(sizeof(char* ) * count);
for(int i=0;i<count;i++)
{
*(array +i) = (char *)malloc(sizeof(char) * 1000);
}
for(int i=0;i<count;i++)
{
fgets(*(array + i) , 1000 , stdin);
}
for(int i=0;i<count;i++)
{
printf("%s:::",*(array+i));
}
printf("\n");
return 0;
}
I am trying to create a string array with count elements. I used fgets function to read elements into the array using for loops. But when i tried to print the elements the last one is missing from the std output. I tried using count =8;
- 1
- 2
- 309876567
- 67564746
- 111
- 20043
- 75647
- 200
These were my inputs. But 200 won't get printed..