Answer the question
In order to leave comments, you need to log in
What is short for?
Good evening, tell me, why did you come up with short
, if there is int
, which also holds 16 bits?
And how to display the value (in the code) how much space it takes, char
or int
for example (and get 8 or 16)?
Answer the question
In order to leave comments, you need to log in
C is designed for all kinds of machines. Some bytes have more than 8 bits - that is, an 8-bit octet is treated as a bitmask. Some are 16-bit, some are 32-bit.
Apparently, int was once the "system size" that size_t is now.
And char, short, long, long long are 1/2/4/8 bytes.
Your "int is 2 bytes" knowledge is outdated - int is 4 bytes on modern machines.printf("%d\n", (int)(sizeof(int) * 8));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question