This question might be very basic but i post here only after days of googling and for my proper basic understanding of signed integers in C.
Actually some say signed int
My doubt is what is the actual range of signed int in c ,1)
[-32767 to 32767]or 2)[-32768 to 32767]?
The whole point of C and its advantage of high portability to old and new platforms is that code should not care.
C defines the range of int with 2 macros: INT_MIN and INT_MAX. The C spec specifies:
INT_MIN is -32,767 or less.
INT_MAX is +32,767 or more.
If code needs a 16-bit 2's complement type, use int16_t. If code needs a 32-bit or wider type, use long or int32least_t, etc. Do not code assuming int is something that it is not defined to be.