Single quotes vs. double quotes in C or C++


In C and C++ the single quote is used to identify the single character, and double quotes are used for string literals. A string literal “x” is a string, it is containing character ‘x’ and a null terminator ‘\0’. So “x” is two-character array in this case.

In C++ the size of the character literal is char. In C the type of character literal is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.

Updated on: 30-Jul-2019

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements