We have used strings in our previous programs several times. Strings are a one-dimensional array of characters assigned between ' '. For example 'Hello World'. Let's have a look at the syntax on how to do program strings in the C language.
char greeting[5] = {'W', 'O', 'R', 'L', 'D'}; |
The C compiler automatically assigns the '\0' (which is a null character) at the end. Have a look at this example program.
Program:
#include <stdio.h>
int main () {
char greeting[8] = {'M', 'O', 'R', 'N', 'I', 'N', 'G', '\0'}; printf("Good morning message: %s\n", greeting ); return 0; } |
Output:
Good morning message: MORNING
In C Language Strings has different properties to change the string into different types.
these properties are