What is printed by this C code: printf(“%zu”, sizeof(long));?
Correct answer D. 8
Explanation
Linux and macOS on 64-bit hardware use the LP64 data model, where long and pointers are 64 bits (8 bytes) while int stays at 4 bytes. The tempting answer 4 is correct only on LLP64 systems such as 64-bit Windows. The C standard fixes only minimum ranges, so long must be at least 32 bits, and the actual size is platform dependent. Assume a typical 64-bit Linux or macOS system here.
Answer checked How we write and check questions
Discussion