, gcc. second
, . first
. , .
, s second = first;
, (a) gcc second
, (b) first
, .
, :
#include <stdio.h>
typedef struct s {
int _;
char str[];
} s;
s first = { 0, "abcdefgh" };
int main(int argc, const char **argv) {
char v[] = "xxxxxxxx";
s second = first;
printf("%p %p %p\n", (void *) v, (void *) &first, (void *) &second);
printf("<%s> <%s> <%s>\n", v, first.str, second.str);
}
32- Linux gcc :
0xbf89a303 0x804a020 0xbf89a2fc
<defgh> <abcdefgh> <abcdefgh>
, v
second
, first
- . , , second
v
, <xxxxxxxx>
<defgh>
.
gcc- . , , second
, , .
Edit: , second
:
s second;
second = first;
- . first
, , , . , first
, , , v
, second.str
- undefined. gcc , first
.