String Empty Check in C++
Level 286 keystrokes
Checks with empty() whether the string s has no characters; s is "", so Empty is printed.
C++ code
// Creates an empty string (length 0)1string s = "";// empty() returns true when the string has no characters2if (s.empty()) { // s is empty, so Empty is printed3 cout << "Empty" << endl;// Runs only if s contains at least one character4} else { // Would print the contents of s; skipped here5 cout << s << endl;6}Output
Empty
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.
<× 8"× 4;× 3(× 2)× 2{× 2}× 2.× 1=× 1