I studied C ++ and came across the following question. I'm just a novice, and I'm embarrassed. Is the sizeof () function supposed to return the size of a data type? Why does the data object have a different size from its sizeof ()? I do not understand the explanation of the answer.
Assume that in a hypothetical machine, the size of char is 32 bits. What will return sizeof (char)?
a) 4
b) 1
c) Implementation dependent
d) Machine dependent
Answer: b
Explanation: The standard does NOT require char to be 8 bits, but requires sizeof (char) to return 1.
source
share