What does int *(cmp)(char*, char*);
mean?
What is the difference between char* ptr1;
and char *ptr2;
this
int *(cmp)(char*, char*);
is a declaration of a function that has the return type int *
and two parameters of the type char *
.
You may enclose a declarator in parentheses. So the above function declaration can be also rewritten like
int * ( (cmp)(char*, char*) );
The both declarations are equivalent to
int * cmp(char*, char*);
A declaration of a pointer to such a function will look like
int * ( *p_cmp )(char*, char*) = cmp;
There is no difference between these declarations
char* ptr1;
char *ptr1;
char * ptr1;