+ 2

Will "a" work?

Will it work if a character is inside a string literal?

11th Jul 2017, 12:08 AM
A_Coders
A_Coders - avatar
3 ответов
+ 6
'a' is a character. "a" is a string of size 1 ( contains 1 character ).
11th Jul 2017, 2:03 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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
11th Jul 2017, 12:10 AM
Complex
Complex - avatar
+ 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)
11th Jul 2017, 12:28 AM
Andrés04_ve
Andrés04_ve - avatar