Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "short int" and "short" in c? [duplicate]

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

like image 581
Narasimha Reddy.P Avatar asked Feb 04 '15 10:02

Narasimha Reddy.P


2 Answers

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.

like image 184
Yu Hao Avatar answered Sep 20 '22 08:09

Yu Hao


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

like image 26
Gopi Avatar answered Sep 21 '22 08:09

Gopi