Working with Text
7 min · C++
Join std::string values, measure them, and change case.
C++ · Working with Text0/5 cleared
Enemy 1 of 5
std::string and concatenation
C++ text lives in the string type, which comes from the <string> header (usually written std::string, but using namespace std; lets you drop the std:: prefix). Unlike a raw C-style character array, std::string manages its own memory, so it can grow, shrink, and be compared with == without you writing any low-level bookkeeping code.
The + operator joins (concatenates) two strings into a new one. This is the same + symbol used for adding numbers, but C++ figures out from the types involved that you mean "glue these pieces of text together" rather than "add these numbers."
You
Packet Wolf
Loading editor...
Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Hello, Ada