Assume this code:
#include <stdio.h>
int a(){
int b = 5;
return b;
}
int main ()
{
printf("%d\n", sizeof(a));
return 0;
}
Above prints 1
. What does that mean?
I know when sizeof
is used on a struct, it gets the total size of the data types within it in bytes. But what does it mean when it's used on a function?
Edit:
What if I do sizeof(a()))
instead of sizeof(a))
. Now it's printing 4
which is the size of the return type, is this the correct way? how is it not undefined?