The string literals are the set of characters which is enclosed in double quotes(“ “). Wide-string literals are prefixed with L always.
Types of string literals −
| Sr.No. | String Literals & Description |
|---|---|
| 1 | “ “ Unprefixed string literal |
| 2 | L” “ Wide-string literal |
| 3 | u8” “ UTF-8 encoded string literal |
| 4 | u” “ UTF-16 encoded string literal |
| 5 | U” “ UTF-32 encoded string literal |
| 6 | R” “ Raw string literal |
Here is an example of string literal in C++ language,
Example
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main() {
wchar_t s[] = L"hello world!";
wcout << L"The uppercase string : ”" << L"\"is ";
for (int i = 0; i < wcslen(s); i++)
putwchar(towupper(s[i]));
return 0;
}Output
Here is the output
The uppercase string : ""is HELLO WORLD!