Accepting Words in 2D
2D array of string means a 2D character array. The row specifies the no. of strings and the column the max length of any string in that array To accept a multiple word value use gets function
/*
http://www.ProbCOMP.com
2D array of string means a 2D character array. The row specifies the no. of strings and the column the max length of any string in that array.
To accept a multiple word value use gets function
*/
#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++)
{
gets(names[i]);
}
printf("\n\nYOU ENTERED\n");
for(int i=0;i<5;i++)
{
printf("%s\n",names[i]);
}
}
Download Program


