As I know, I can determine the type of function:
typedef void (fn)(void);
and I can also determine the type of function pointer:
typedef void (*pfn)(void);
There are 2 functions. The first type of function parameter is a function, and the other is a pointer to a function:
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 argument 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 are they really the same?
source share