I want to ask the user to give me five questions, and then I want to print out these five questions. I am using a for loop. It works for the first questions and then it stops working. Thank you in advance.
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
char *question [5];
question[5] = (char*) malloc(5 * sizeof(char));
for (int i = 0; i < 5; ++i)
{
printf("enter question number %i\n", i+1);
scanf("%[^\n]%*c", question[i]);
printf("%s\n", question[i]);
}
free (question[5]);
return 0;
}