Concatenating String Literals
Sometimes a string may be too long to conveniently fit on one line of code. C++ enables you to concatenate string literals—that is, to combine two quoted strings into one. Indeed, any two string constants separated only by whitespace (spaces, tabs, and newlines) are automatically joined into one. Thus, all the following output statements are equivalent to each other:
cout << "I'd give my right arm to be" " a great violinist.\n";cout << "I'd give my right arm to be a great violinist.\n";cout << "I'd give my right ar""m to be a great violinist.\n";
Note that the join doesn’t add any spaces to the joined strings. The first character of the second string immediately follows the last character, not counting \0, of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access