Ticker

6/recent/ticker-posts

Array of string in c in hindi

 

Array of String in C –

Array of string एक Two Dimensional Array होता है l यह Table के रूप में स्टोर होता है जिसमे Row और Column होता है l

SYNTAX – char array_name [num_string][length_string];

 

Example – char arr[2][5];

 

Initialization 1–

char ch_arr[3][10] = {

                                     {'s', 'p', 'i', 'k', 'e', '\0'},

                                     {'t', 'o', 'm','\0'},

                                     {'j', 'e', 'r', 'r', 'y','\0'}

                                     };

Initialization 2–

 

char str_arr[2][10] ={“stech”, ”institute”};

 

Program.1 –

#include <stdio.h>

#include<conio.h>

 

main()

{

 

char ch[3][10],i;

printf("Enter 3 Strings\n");

for(i=0;i<3;i++)

{

    scanf("%s",ch[i]);

}

printf("Strings are:\n");

for(i=0;i<3;i++)

{

    printf("\n%s",ch[i]);

}

getch();

return 0;

}

Output –

Enter 3 Strings :

                            Hii

                            Hello

                            Welcome

Strings Are:

                            Hii

                            Hello

                            Welcome

Post a Comment

0 Comments