
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What is the type of string literals in C/ C++?
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!
- Related Articles
- What is the type of string literals in C and C++?
- What are string literals in C#?
- What are string literals in C language?
- Type difference of character literals in C and C++
- Type difference of character literals in C vs C++
- Formatted string literals in C#
- What does the @ prefix do on string literals in C#?
- What happen if we concatenate two string literals in C++?
- What is the difference between character literals and string literals in Java?
- Character constants vs String literals in C#
- What are literals in C++?
- What are Boolean Literals in C++?
- What are Character Literals in C++?
- What are integer literals in C#?
- Literals in C#

Advertisements