String Substring in C++
Level 263 keystrokes
Uses substr(0, 5) to take the first 5 characters of "Hello World" and prints Hello.
C++ code
// Stores "Hello World" in the string text1string text = "Hello World";// substr(pos, len) returns a new string of len characters starting at pos// From index 0, 5 characters gives "Hello"; text itself is unchanged2cout << text.substr(0, 5) << endl;Output
Hello
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;× 2"× 2,× 1.× 1(× 1)× 1=× 1