String Compare in C++
Level 265 keystrokes
Compares two strings with ==, which checks their contents; both are "hello", so the result true is printed as 1.
C++ code
// Creates the string a with "hello"1string a = "hello";// Creates a separate string b with the same text2string b = "hello";// For std::string, == compares the characters, not memory addresses// a == b is true, and cout prints a bool as 1 (false would be 0)3cout << (a == b) << endl;Output
1
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
"× 4<× 4=× 4;× 3(× 1)× 1