I came across a multi-line string while doing an inspection on a colleagues C code. I’ve never seen this sort of thing before, and didn’t know it was possible.
Something like this:
char* welcomeMessage = "Hello "
"Dale. "
"How are you?";
printf("%s", welcomeMessage);
will happily print out “Hello Dale. How are you?”.
It seems that you can define a string literal in C across multiple lines, without any need for a concatenation character (like ‘+’ in Java and C#).
I like that, even though I’ve been writing C for years now, I still occasionally come across little bits and pieces in the language that are new to me. And doing code inspections and reviews of other people’s code are a good way to share this sort of stuff and learn from each other.
