+ 2
Will "a" work?
Will it work if a character is inside a string literal?
3 ответов
+ 6
'a' is a character.
"a" is a string of size 1 ( contains 1 character ).
+ 2
Yes "a" "b" "x" is considered strings since it has double qoutation marks in C++ you have to tell the compiler what data type you're using so doing
char x = "a"; is char x = 'a';
string f = "x"; //No error
+ 1
Also " are used with old C strings (arrays of chars) but it souldn't be larger than array size-1 (it adds an string-end \0 character)