For example result of this code snippet depends on which machine: the compiler machine or the machine executable file works?
sizeof(short int)
For example result of this code snippet depends on which machine: the compiler machine or the machine executable file works?
sizeof(short int)
It depends on the machine executing your program. But the value evaluates at compile time. Thus the compiler (of course) has to know for which machine it's compiling.
sizeof is evaluated at compile time, but if the executable is moved to a machine where the compile time and runtime values would be different, the executable will not be valid.
#include<stdio.h>
void f(int n)
{
char pp[n];
printf("%d\n",sizeof(pp));
}
int main()
{
int n;
scanf("%d",&n);
f(n);
}
In this program the size of array is defined at runtime,and sizeof operator is printing correct size after runtime initialisation in gcc 4.4. Can anybody explain???