wartość domyślna dla elementu struktury w C
Czy można ustawić wartości domyślne dla jakiegoś elementu struktury? Próbowałem wykonać następujące czynności, ale spowodowałoby to błąd składniowy:
typedef struct
{
int flag = 3;
} MyStruct;
Błędy:
$ gcc -o testIt test.c
test.c:7: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
test.c: In function ‘main’:
test.c:17: error: ‘struct <anonymous>’ has no member named ‘flag’