C (and therefore
C++ too) lets you create
string literals by pasting several literals together. This is achieved by placing them adjacently. So "the quick brown fox" and "the quick" "brown fox" are 2 ways of specifying the
same string literal.
Note that this only works for string literals; you cannot expect C to give character arrays any special treatment.
What's it good for? Good question, but there are good reasons to use it:
- Split a long literal along several lines of code:
printf("The rain it raineth on the just\n"
"And also un the unjust fella.\n"
"But chiefly on the just;\n"
"For the unjust's stolen the just's umbrella.\n");
- Incorporate C preprocessor constants in the string:
#define XYZ "letters"
char xyz<> = "XYZ = \"" XYZ "\"";
See also int32 for a real-world example.
- Incorporate stringified preprocessor values in the string. See #x and the stringize macro macro hack for examples.