How to write a C program Array of strings in C programming ?
Besides data base applications, another common application of two dimensional arrays is to store an array of strings.A string is an array of characters; so, an array of strings is an array of arrays of characters. Of course, the maximum size is the same for all the strings stored in a two dimensional array. We can declare a two dimensional character array of MAX strings of size SIZE as follows:
char names[MAX][SIZE];
Solution:
#include <stdio.h>
int main()
{
char str[10][100];
int i, n;
printf("How many names? ");
scanf("%d", &n);
getchar();
for(i = 0; i < n; i++)
gets(str[i]);
for(i = 0; i < n; i++)
puts(str[i]);
return 0;
}