Question
How do I print the size of int in C?
I am trying to compile the below on RHEL 5.6 , 64 bit, and i keep getting a warning
"var.c:7: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’"
Here is my code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned int n =10;
printf("The size of integer is %d\n", sizeof(n));
}
It does not matter if i change the declaration for "n" to following
- signed int n =10;
- int n = 10;
All i want to do is print the size of integer on my machine, without really looking into limits.h.