C Programming - Complicated Declarations - Discussion

10. 

What do the following declaration signify?

void (*cmp)();

[A]. cmp is a pointer to an void function type.
[B]. cmp is a void type pointer function.
[C]. cmp is a function that return a void pointer.
[D]. cmp is a pointer to a function which returns void .

Answer: Option D

Explanation:

No answer description available for this question.

Amit Saxena said: (Jul 28, 2014)  
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 ?

Elayaraja said: (Dec 10, 2014)  
@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.

Mohd Israr said: (Mar 18, 2015)  
@Amit.

Can you explain us why the answer is not appropriate?

Natwar said: (Jun 30, 2015)  
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;
}

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.