thetna
thetna

Reputation: 7143

Difference between unsigned and unsigned int in C

Could you please make it clear what the difference is between unsigned and unsigned int? Maybe some example code would be helpful.

Upvotes: 49

Views: 24295

Answers (5)

Daniel
Daniel

Reputation: 6775

unsigned alone means unsigned int. You can also use unsigned char, etc. I have no idea what happens if you try unsigned double or unsigned float. Anybody know?

Upvotes: 11

Graham Borland
Graham Borland

Reputation: 60711

unsigned is a modifier which can apply to any integral type (char, short, int, long, etc.) but on its own it is identical to unsigned int.

Upvotes: 79

Sander De Dycker
Sander De Dycker

Reputation: 16243

There is no difference. unsigned and unsigned int are both synonyms for the same type (the unsigned version of the int type).

Upvotes: 15

Heisenbug
Heisenbug

Reputation: 39194

They are exactly the same thing.

Upvotes: 3

Mu Qiao
Mu Qiao

Reputation: 7107

unsigned indicates that it's unsigned int. So they are equivalent.

Upvotes: 4

Related Questions