- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Difference between C++ string constants and character constants
In C++, a character in single quotes is a character literal. It's of type char. For example, 'a' is of type char with a value 97 on an ASCII based system.
A character or a string of characters together in double quotes represent a string literal. It's of type const char[] and refers to an array of size length of string + 1. That extra character is there for marking the string's ending.
String literals can be arbitrarily long, such as "abcdefg". Character literals almost always contain just a single character. When these are being printed, string literals are printed till the first \0 or NULL character is encountered in the string.
- Related Articles
- Character constants vs String literals in C#
- What are C++ Character Constants?
- Data type of character constants in C and C++
- How to define character constants in C#?
- Difference between constants and final variables in Java?
- What is the difference between constants and variables?
- What are Backslash character constants in C language?
- Relation between Elastic Constants
- C# TicksPer constants
- How do I define string constants in C++?
- Decimal constants in C#
- PHP Constants
- What are constants in C++?
- What are C++ Integer Constants?
- How to create Variables and Constants in C++?

Advertisements