13

what is the difference between declaring the variables as short int and short? In gcc compiler the short occupies 2 bytes(checked with sizeof(short)),and short int is also giving the 2bytes of size.Is both are same are different?In which case these declarations will helpful?

Thanks In Advance

2 Answers2

15

short is short for short int, they are equivalent in any C compiler.

The same for long int vs long, long long int vs long long.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
4

short, short int, signed short int, and signed short are all same data-types.

So sizeof(short) == sizeof(short int)

The same goes for long

Gopi
  • 19,784
  • 4
  • 24
  • 36