2D String Array
An array is a contiguous block of memory.In a 2D array there are many rows. A string is an array of characters so if we pass just the address of every row we can scan the elements.
/*
http://www.ProbCOMP.com
An array is a contiguous block of memory.In a 2D array there are many rows.The total number of elements in the array is row x column.
A string is an array of characters so if we pass just the address of every row we can scan the elements.
*/
#include<stdio.h>
void main()
{
char names[5][20];
// The row repesents no. of strings and col represents length of the string
printf("enter 5 strings of length not more than 20 each\n");
for(int i=0;i<5;i++)
{
scanf("%s",names[i]);
}
printf("\n\nYOU ENTERED\n");
for(int i=0;i<5;i++)
{
printf("%s\n",names[i]);
}
}
Download Program


