I have initialized a structure of static with function name as shown below.
We have to initialize a static structure with constants. Is function names are constants in C?
struct fp {
int (*fn)();
};
int f1()
{
printf("f1 called \n");
return 0;
}
static struct fp fps = {
.fn = f1,
};
int main()
{
fps.fn();
return 0;
}
If is compiling without any issues when initialized the structure as shown below.
static struct fp fps = {
.fn = &f1,
};
In C for a function name both f1 and &f1 are same?