I always thought that in C, int
stands for signed int
; but I have heard that this behavior is platform specific and in some platforms, int
is unsigned
by default. Is it true? What says the standard, and has it evolved over time?
You are quite right. As per C11
(the latest c standard), chapter §6.7.2
int
,signed
, orsigned int
is categorized as same type (type specifiers, to be exact). So, int
is the same as signed int
.
Also, re-iterating the same, from chapter §6.2.5/P4
There are five standard signed integer types, designated as
signed char
,short int
,int
,long int
, andlong long int
. (These and other types may be designated in several additional ways, as described in 6.7.2.) [....]
So, for any conforming environment, int
stands for signed int
and vice versa.