I understand that: I can use a two-dimensional array for storaging many strings. But, I would like to solve this problem with one-dimensional; so, please do not advise me to use two-dimensional array for solving.
I have a small one-dimensional array, which is used for storaging many strings. Here is all of source code:
#include <stdio.h>
void main()
{
#define MAX 10
int N = 3;
char * str[MAX];
printf("Input a string in each line:\n\n");
for (int i = 0; i < N; i++)
{
printf("str[%d] = ", i);
gets(str[i]);
}
printf("\n\n---\n\nExport the list of strings:\n\n");
for (int j = 0; j < N; j++)
{
printf("str[%d] = ", j);
printf("%s\n", str[j]);
}
}
When I compile it, the compiler does not return any error or warning. But, after I inputted the data, there is an error message from Windows:
A problem caused the program to stop working correctly
Then, my program is broken.