I
I
Ingerniated2017-09-11 18:08:03
C++ / C#
Ingerniated, 2017-09-11 18:08:03

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, charor intfor example (and get 8 or 16)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2017-09-11
@Ingernirated

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 question

Ask a Question

731 491 924 answers to any question