One of the answers к Why do you not use C for your web apps? содержит следующее:C конкатенация констант
For the C crap example below:
const char* foo = "foo"; const char* bar = "bar"; char* foobar = (char*)malloc(strlen(foo)+strlen(bar)+1); strcpy(foobar, foo); strcat(foobar, foo);
Actually, constants CAN AND SHOULD be concatenated naturally in C:
const char foo[] = "foo"; const char bar[] = "bar"; char foobar[] = foo bar; // look Ma, I did it without any operator!
And using [] instead of * will even let you modify the string, or find their length:
int foo_str_len = sizeof(foobar)-1;
So, PLEASE, before you (falsely) claim that C is difficult to use with strings, learn how to use C.
Я пробовал сам, но получаю сообщение об ошибке:
expected ‘,’ or ‘;’ before string constant
Так что мой вопрос: Должен ли я нужно сказать компилятору что-то, чтобы сделать эту работу, или это сообщение выше, просто неправильно? Обратите внимание, что я знаю о других способах конкатенации массивов символов в C.
Этот ответ вздор. –