Strings are mainly defined as an array of characters. In simple words it is one dimensional array of characters which is terminated by null ('/0') character.
Syntax:
datatype array_name[size of array];
{
//block of code
}
How it works?
char str[]="Hello";
Syntax:
datatype array_name[size of array];
{
//block of code
}
How it works?
char str[]="Hello";
Above image shows the memory representation of string with their index and memory address.
#include<stdio.h>
void main()
{
char str[]="Hello";
printf("%s",str);
}
Example program of string:
#include<stdio.h>
void main()
{
char str[]="Hello";
printf("%s",str);
}
No comments:
Post a Comment
If you have any doubts, please discuss here...