Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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!
Advertisements