- C language
- C type
- here
int type --signed integer type of 16 bits or more
The int type is a signed integer type that is guaranteed to be 16 bits or more by specification. In many implementations, it may be implemented as a 32-bit signed integer type, but that is not guaranteed by the C language specifications.
#include <stdio.h> int main (void) { int num = 34; printf("%d\n", num); }
Integer type that guarantees width and signing / unsigned introduced in C99
To ensure that the bit width and signed / unsigned are specified, use the following integer types introduced in C99. This is recommended for numerical calculations.
- int8_t --Signed 8-bit integer type
- int16_t --Signed 16bit integer type
- int32_t --Signed 32-bit integer type
- int64_t --Signed 64-bit integer type
- uint8_t --Unsigned 8bit integer type
- uint16_t --Unsigned 16bit integer type
- uint32_t --Unsigned 32bit integer type
- uint64_t --Unsigned 64-bit integer type
Is the return value of main an int type?
The return value of main is an int or a type compatible with the int.
In the implementation, if the width of the int type is 32bit, it is okay to use the int32_t type as the return type of the main function, but it is not recommended to write a description that depends on the implementation.
Let's make it an int type obediently.
When performing numerical operations, implicit type conversion is used, and values smaller than int type become int type
When performing numerical operations, implicit type conversion is used to convert values smaller than int type to int type. It is covered in detail in the following articles.