Something is not going right in the following code. I am taking an array of strings from user and printing at the same time. Array can have noe no. of strings, as noe is entered by user.
#include <stdio.h>
int main(){
char **p;
int noe=0,i=0,j=0;
scanf("%d", &noe);
p=malloc( noe * sizeof(char *) );
for(j=0;j<noe;j++)
{
p[j]=malloc( 25* sizeof(char *) );
}
for(j=0;j<noe;j++){
//takes events as x y time
gets(p[j]);
puts(p[j]);
}
return 0;
}
When I give noe as 5,( the no. of strings user wants to enter), loop goes for 4 times only and I am able to give input for 4 strings??
Expected Output:-
5
Alice
Marry
Jane
Allen
john
Actual Output :-
5
Alice
Marry
Jane
Allen
Why there is an empty line in output? and Why I am not allowed to enter 1 last input