Bite Bytes
Bite Bytes

Reputation: 1513

Why int exists in C, Why not just short and long

A short is at least 16 bits and a long is at least 32 bits, so what's the point of an int which can be either 16-bit or 32-bit?

PS: I'm talking about ANSI C here.

Upvotes: 1

Views: 270

Answers (1)

Sourav Ghosh
Sourav Ghosh

Reputation: 134306

short, int and long are by definition three different Type specifiers, where, short int ranks lower than int which ranks lower than long int.

C standard only specifies the minimum (and comparative, for example, int cannot be wider than long) requirements, an implementation may choose to provide any other wider definition of the types, keeping the constraints alive.

Upvotes: 3

Related Questions