C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Point Out Errors (Q.No. 3)
3.
Point out the error in the following program.
#include<stdio.h>
void display(int (*ff)());
int main()
{
int show();
int (*f)();
f = show;
display(f);
return 0;
}
void display(int (*ff)())
{
(*ff)();
}
int show()
{
printf("IndiaBIX");
}
Discussion:
17 comments Page 1 of 2.
Tom said:
2 years ago
I am not understanding this. Anyone, Please help me to get it.
Dave said:
7 years ago
Technically, the function show() should return a value, since it is declared [int show()].
Rohan said:
7 years ago
@ALL.
Step 1: void display(int (*ff)()); ->a display is a function with a arguement as [*ff pointer function which is integer ] and its returns type of the function (display ) is void ..
int show();
Step 2: a function[ show() ] is declared as integer.
int (*f)();
Step 3: a pointer function [*f()] is declared as f.
f = show();
Step 4: It should store the content of show() function
display(f);
Step 5: displays the content of f.
void display(int (*ff)())
{
(*ff)();
}
Step 6: definition of the function[display]
int show()
{
printf("IndiaBIX");
}
Step 7: It will define the function show() and print IndiaBix.
Step 1: void display(int (*ff)()); ->a display is a function with a arguement as [*ff pointer function which is integer ] and its returns type of the function (display ) is void ..
int show();
Step 2: a function[ show() ] is declared as integer.
int (*f)();
Step 3: a pointer function [*f()] is declared as f.
f = show();
Step 4: It should store the content of show() function
display(f);
Step 5: displays the content of f.
void display(int (*ff)())
{
(*ff)();
}
Step 6: definition of the function[display]
int show()
{
printf("IndiaBIX");
}
Step 7: It will define the function show() and print IndiaBix.
(1)
Disha said:
8 years ago
int (*f)();
f = show;
f is a pointer to the function replace f by show int (*show)(); So it was correct I guess.
f = show;
f is a pointer to the function replace f by show int (*show)(); So it was correct I guess.
Priya said:
9 years ago
But show is a function, then f = show how it can be possible?
It should be f=show(). So, here is an error.
It should be f=show(). So, here is an error.
Jyothi said:
9 years ago
I don't understand please explain anyone.
Gaurav said:
9 years ago
Show function has not been declared. Then how the error will not generate?
Amey said:
9 years ago
There should be an error option because the return type of function show() is int but it is not returning anything.
Raja said:
10 years ago
What is the meaning of (*ff)();?
Nivetha said:
10 years ago
How come f=show comes rights? Its an error.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers