One of the answers-Why do you not use C for your web apps? contiene quanto segue:C concatenazione di stringhe di costanti
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.
ho provato io stesso, ma un errore:
expected ‘,’ or ‘;’ before string constant
Quindi la mia domanda è: Devo devo dire al compilatore qualcosa per far funzionare questo o semplicemente il post sopra è sbagliato? Si noti che sono a conoscenza di altri modi per concatenare gli array di caratteri in C.
Questa risposta è una sciocchezza. –