In some code I today read, a type of C-String initialisation existed which is new to me.
It chains multiple String-Initialisation like "A""B""C"...
It also allows splinting the String Initialisation to multiple Lines
I set up a small Hello World demo, so you can see what I am talking about:
#include <stdio.h>
#define SPACE " "
#define EXCLAMATION_MARK "!"
#define HW "Hello"SPACE"World"EXCLAMATION_MARK
int main()
{
char hw_str[] =
"Hello"
SPACE
"World"
"!";
printf("%s\n",hw_str);
printf("%s\n",HW);
return 0;
}
So here are some questions:
- is this valid according to the standard?
- why this works? "abc" is like a array {'a','b','c'} right?, so why are array initialisations concatenated over multiple pairs of "" working?
- has this feature an official name - like when you enter it in google, you find some documentation describing it?
- is this portable?