Ticker

6/recent/ticker-posts

C Language (String array in C)

STRING ARRAY IN C

String values are consisted with number of characters and terminated by a special character NULL (\0).

C language does not support string as data type, actually string is one dimensional array of character data type in C language.






STRING ARRAY EXAMPLE - I
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char name[] ={'R', 'a', 'k', 'e', 's', 'h'};
printf("%s", name);
getch();
}

----------------------------
         OUTPUT 
----------------------------

Rakesh






STRING ARRAY EXAMPLE - II
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char name[40];
printf("Enter your name: ");
scanf("%s", &name);
printf("Welcome ...%s", name);
getch();
}



----------------------------

         OUTPUT 
----------------------------

Enter your name: Rakesh
Welcome ... Rakesh















Post a Comment

0 Comments