String Append in C++

Level 262 keystrokes

Builds a string step by step with +=: "Hello", then a space, then "World", and prints Hello World.

C++ code

// Starts the string s with "Hello"
1string s = "Hello";
// += appends to the end of s, which becomes "Hello "
2s += " ";
// Appends "World", so s is now "Hello World"
3s += "World";
// Prints Hello World
4cout << s << endl;

Output

Hello World
Practice typing this code

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.

  • "× 6
  • ;× 4
  • <× 4
  • =× 3
  • +× 2

More C++ examples at level 2

← C++ typing practice