When I write the following code, I get the expected error error: array size missing in 'data'
.
int main()
{
unsigned char data[];
return 0;
}
However, when I run the same code but wrap the offending line inside a struct
, there are no errors.
typedef struct credit_card_s
{
unsigned char is_valid;
unsigned char data[];
} credit_card_t;
Can anyone explain to me why this is allowed? Shouldn't both of them encounter the same error?