As I know, I can define a function type:
typedef void (fn)(void);
and I can also define a function pointer type:
typedef void (*pfn)(void);
There are 2 functions. The first function's parameter type is a function, and the other is a function pointer:
void a(fn fn1)
{
fn1();
}
void b(pfn fn1)
{
fn1();
}
I implement a function callback:
void callback(void)
{
printf("hello\n");
}
and pass it as the argument to a and b:
int main(void) {
a(callback);
b(callback);
return 0;
}
Both a and b work well, and print "hello"
.
So I want to know what is the difference between defining a function type and a function pointer type? or actually, they are same?