C++ Double Quotes VS Single Quotes

LeetViet

Platinum Member
Mar 6, 2003
2,411
0
76
When is it right to use a double quote/single quote?
Are characters surrounded by single quotes and strings surrounded by double quotes?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
more precisely, 'a' is a single character, "a" is treated as (or a pointer to) an array of characters.

char c = 'a' ; // valid
char c = "a" ; // trying to assign pointer to char
char* c = "a"; // valid again
 

LeetViet

Platinum Member
Mar 6, 2003
2,411
0
76
I'm going to assume assigning decimal values, float values, and boolean values do not require quotes?

I'm trying to write the neatest code possible.
 

akubi

Diamond Member
Apr 19, 2005
4,392
1
0
Originally posted by: LeetViet
I'm going to assume assigning decimal values, float values, and boolean values do not require quotes?

I'm trying to write the neatest code possible.

it's required that you don't put quotes around them
 

LeetViet

Platinum Member
Mar 6, 2003
2,411
0
76
Originally posted by: akubi
Originally posted by: LeetViet
I'm going to assume assigning decimal values, float values, and boolean values do not require quotes?

I'm trying to write the neatest code possible.

it's required that you don't put quotes around them

Gotcha, I never did but never hurts to be sure. :)