In C programming, a string is a sequence of characters terminated with a null character \0. For example:
char c[] = "c string";
When the compiler encounters a sequence of characters enclosed in the double quotation marks, it appends a null character \0 at the end by default.
Memory diagram of strings in C programming
Memory Diagram
How to declare a string?
Here's how you can declare strings:
char s[5];
string declaration in C programming
String Declaration in C
Here, we have declared a string of 5 characters.
How to initialize strings?
You can initialize strings in a number of ways.
char c[] = "abcd";
char c[50] = "abcd";
char c[] = {'a', 'b', 'c', 'd', '\0'};
char c[5] = {'a', 'b', 'c', 'd', '\0'};
Initialization of strings in C programming
String Initialization in C