String is a collection of characters in an array.It is terminated by by \0 (null character)
There are two ways to declare string in c language.
1)By char array
declaring string by char array is as follows:
char ch[10]={'e','v','o','n', '\0'};
2)By string literal
declaring string by string literal is as follows:
char ch[]="Evon Tech";
String Example
#include <stdio.h>
void main ()
{
char ch[11]={'e', 'v', 'o', 'n', 't', 'e', 'c', 'h', '\0'};
char ch2[11]="Evon Tech";
printf("Char Array Value is: %s\n", ch);
printf("String Literal Value is: %s\n", ch2);
}
0 Comment(s)