- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 do single quotes do in C++ when used on multiple characters?
In C++ th
In C++ the double quotes are used as string literals, and single quote with one character is used as character literals. Now here we will see what will be the output if we try to print a multi-character string using the single quote.
Example Code
#include<iostream> using namespace std; main() { cout << 'ABCD'; }
Output
1094861636
This program returns a large number as output. Now the question is what is the significance of this number?
This number is not some memory address. It is generated from the ASCII values of those characters. In this example we have used A, B, C, D. In Hex the ASCII values of them are 41, 42, 43 and 44. So if we place the number one after another, then the hex code will be like 41424344. Now after converting this into decimal, it will return 1094861636.
Advertisements