...
Non-Compliant Code Example
One would expect the the example below to output sizeof(size_t) + (sizeof(char) * 50)
. However, this may not be the case. Assuming sizeof(size_t)
is 4, the example may actually evaluate the size of buf
to be 56 due to padding.
Code Block |
---|
struct struct buffer { size_t size; char buffer[50]; }; int main(int argc, char *argv[]) { struct buffer buf; printf("%u",sizeof(buf)); return 0; } |