String Literals
String literals are similar to that character literals, except that they can store multiple characters and uses a double quote to store the same. It can also accommodate the special characters and escape sequences mentioned in the table above. We can break a long line into multiple lines using string literal and can separate them with the help of white spaces.
Example:
char stringVal[] = "w3wiki";
Example:
C
#include <stdio.h> int main() { const char str[] = "Welcome\nTo\nGeeks\tFor\tGeeks" ; printf ( "%s" , str); return 0; } |
Output:
Welcome
To
Geeks For Geeks
Must Read:
Literals in C
In C, Literals are the constant values that are assigned to the variables. Literals represent fixed values that cannot be modified. Literals contain memory but they do not have references as variables. Generally, both terms, constants, and literals are used interchangeably.
For example, “const int = 5;“, is a constant expression and the value 5 is referred to as a constant integer literal.