C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - General Questions (Q.No. 10)
10.
What do the following declaration signify?
void (*cmp)();
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;
}
#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?
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.
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 ?
Or else explain the difference between Q10 and Q8 ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers