I want to check the size, max value, and min value of data type int, long and their unsigned form. The output of my program shows that both int and long have the same size, max, and min value, same goes to their unsigned form. Here is the output of my program:
Size of int : 4 byte, Max value : 2147483647, Min value : -2147483648
Size of long : 4 byte, Max value : 2147483647, Min value : -2147483648
Size of unsigned int : 4 byte, Max value : 4294967295, Min value : 0
Size of unsigned long : 4 byte, Max value : 4294967295, Min value : 0
And here is my code:
#include <stdio.h>
#include <limits.h>
int main(int argc, char *argv[])
{
printf("Size of int : %ld byte, Max value : %d, Min value : %d\n", sizeof(int), INT_MAX, INT_MIN);
printf("Size of long : %ld byte, Max value : %d, Min value : %d\n", sizeof(long), LONG_MAX, LONG_MIN);
printf("\n");
printf("Size of unsigned int : %ld byte, Max value : %u, Min value : %d\n", sizeof(unsigned int), UINT_MAX, 0);
printf("Size of unsigned long : %ld byte, Max value : %lu, Min value : %d\n", sizeof(unsigned long), ULONG_MAX, 0);
return 0;
}
My question is, is this normal that int and long have the same size, max value, and min value? I am running the program using gcc version 5.1.0 (tdm64-1) compiler on Windows 10 64-bit machine.
7:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat=]correct that to%ld.%zuto printsize_tvalues (such as those fromsizeof).