C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - General Questions (Q.No. 10)
10.
What do the following declaration signify?
void (*cmp)();
cmp is a pointer to an void function type.
cmp is a void type pointer function.
cmp is a function that return a void pointer.
cmp is a pointer to a function which returns void .
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Natwar said:   10 years ago
Example for cmp is a pointer to a function which returns void:

#include<stdio.h>

void cmp (void)
{
printf("Example for Function Pointer");
}
int main()
{
void (*fun_ptr)(void); //Syntax for Function pointer
fun_ptr = cmp;
fun_ptr();
return 0;
}

Mohd israr said:   1 decade ago
@Amit.

Can you explain us why the answer is not appropriate?

Elayaraja said:   1 decade ago
@Saxena.

The above answer is correct because here cmp is function pointer, which is pointing to a function which return nothing (void). Since it's correct.

Amit Saxena said:   1 decade ago
The answer is not appropriate as the function is declared as no return type using parenthesis. if the declaration would been void *cmp(); then this answer might be right.

Or else explain the difference between Q10 and Q8 ?

Post your comments here:

Your comments will be displayed after verification.