One of the answers do Why do you not use C for your web apps? zawiera następujące elementy:C konkatenacji ciąg stałych
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.
Próbowałem to sam, ale pojawia się błąd:
expected ‘,’ or ‘;’ before string constant
Więc moje pytanie brzmi: czy ja trzeba powiedzieć kompilatorowi coś, aby to działało lub czy powyższy post jest po prostu błędny? Należy pamiętać, że jestem świadomy innych sposobów łączenia tablic znaków w C.
Ta odpowiedź to nonsens. –