String stream in C++
Level 3109 keystrokes
A stringstream works like cout but writes into a string. Text and numbers are combined with <<, and str() returns the result "Value: 42, Pi: 3.14".
C++ code
// An output target in memory (needs <sstream>)1stringstream ss;// << converts the numbers to text and appends everything, just like with cout2ss << "Value: " << 42 << ", Pi: " << 3.14;// str() returns the accumulated text as a string3string result = ss.str();// Prints Value: 42, Pi: 3.144cout << result << endl;Output
Value: 42, Pi: 3.14
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.
<× 12;× 4"× 4:× 2.× 2,× 1(× 1)× 1=× 1