Thursday, July 30, 2009

In C++ does the data type short take only two bytes of memory?

I know char takes one byte and int takes 4 bytes, but my C++ books does not state if short takes up less memory. I am assuming is does. I know in java short takes up less memory.

In C++ does the data type short take only two bytes of memory?
Yes. Only 2 bytes.
Reply:A short must contain at least 16 bits, but there is no requirement


that an implementation uses only 2 bytes of storage.





Typically, it is 2 bytes, but you need to ask about specific


processors and compilers to get a definitive answer.


No comments:

Post a Comment