Strings in C

Strings are a group of an array of characters. Followed by null (‘\0) character at the end of a string.

The Syntax for a String is below:
char String-name[size of String];


 


The Example for a String is the following:

char string[25];               //Statement 1

Note: The character array can hold twenty-five characters at a time.

Another example of a String is the following:

#include <stdio.h>
 int main () {
        char greeting[3] = {'H', 'i',  '\0'};
        printf("Message: %s\n", greeting );
        return 0;
 }

Result:
Message: Hi


Coding Tag

Coding Tag always happy to serve you in Information Technology (IT). Learn HTML, CSS, Javascript, PHP, Android, Digital Marketing, Latest IT News and many more.

Leave a Reply

avatar
  Subscribe  
Notify of