Strings are mainly defined as an array of characters. In simple words it is one dimensional array of characters which is terminated by special character called the null ('/0') character.
In simple words string is a line of characters, like a word or a sentence. Each character in the string is stored in a specific memory location, and the null character marks the end of the string.
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);
}
Above program shows the following output:
To explore the exercises and examples of String click Here...
No comments:
Post a Comment
If you have any doubts, please discuss here...👇