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