Interview Question
0of 0 votesint fun(char *a){
printf("%d\n",sizeof(a));
return 1; }
int main()
{
char a[20];
printf("%d\n",sizeof(fun(a)));
}
Explain the output.
Country: United States
I explained the reason why only printf inside main() is working.
And how compiler is able to calculate size of return type of the function fun().
@shondik : my question is that why is the function not called . Any reason or should i remember it as a rule ?

Output will be 4. An expression is never evaluated inside sizeof operator.
- Aashish on July 02, 2012 Edit | Flag ReplySo, the function will not be called. However, you must be surprising that how the compiler is able to output 4. Its because compiler sees the signature of the function. Change the return type to double & you will see the output 8.