Sizeof operator is compile time operator. converts sizeof expression with constant result values during compile time. [Exception variadic templates c99]
Normally compiler fixes size for variables at compile time. for array n. But when i print sizeof array it gives correct size? is this code allots memory at compile time for n?
How sizeof is evaluated then?
how about the array a[] in function?
int fun(int n)
{
char a[n+3];
return sizeof(a);
}
int
main( )
{
int i;
while(i!=-1){
scanf("%d",&i);
int n[i];
printf("\nsize: %d %d\n",fun(3),sizeof n);
}
}
when i try this : sizeof prints size of n correctly [(sizeof (int)) * i] but the function gives wrong results always 6?
How sizeof is implemented and calculates size (for float,int,...datatypes , variables, array, ...) ?
Any code is appreciated!