#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? we say that sizeof is compile time operator.then ? and C99 give us to have this type of initaliazation. pp[n], it is dynamic.but it is still working ? (above snippet is working correctly in .cpp and .c both correcttly.) thanks alot.