Syntax:-
Char stringarrayname [size1] [size2];
Size1= No. of strings
Size2= No.of char in a string.
Ex:-
Char name [2] [20];
In the above example the name is a string and it contains two strings.
Ex:-
Char name [2] [20];
In the above example the name is a string and it contains two strings.
Each strings contains 20 characters.
#include<stdio.h>
#include<conio.h>
void main()
{
char name[20][30];
int n,i;
clrscr();
printf("enter no of strings:");
scanf("%d",&n);
printf("enter a string:");
for(i=0;i<=n-1;i++)
scanf("%s",&name[i]);
printf("the no. of strings are:\n");
for(i=0;i<=n-1;i++)
printf("%s\n",name[i]);
getch();
}
|
Output:-
________________________________________________________________
________________________________________________________________
Post a Comment