String in C

String in C

String is a collection of characters. They are arranged one after another in memory.

To mark the end of string, C uses the NULL character.

Strings in C enclosed within double quotes.


Example, "My age is 19" is a string.


Initializing String

char month[] = { 'J' , 'a' , 'n' , 'u' , 'a' , 'r' , 'y' , 0 };

Program

        
#include<stdio.h>
int main() {
    char str[ ] = "This is a string literal";
    printf("%s", str);
    return 0;
}           
        
    

Output

        
This is a string literal    
        
    



Join Our Social Media Connections

Post a Comment

0 Comments