Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between int (*cmp)(void) and int *cmp(void)?

Tags:

c

What is the difference between

extern int (*func)(void);

and

extern int *func(void);

Thanks

like image 936
gnued Avatar asked Dec 23 '22 19:12

gnued


1 Answers

extern int (*func)(void);

declares func as a pointer to a function which takes no arguments and returns an int value.

extern int *func(void);

is a forward declaration (a.k.a. a protptype) of func as a function that takes no arguments and returns a pointer to an int.

The first declares a variable, the second declares a function.

like image 83
Some programmer dude Avatar answered Feb 02 '23 00:02

Some programmer dude