I need a pointer which can store a function address.The function return is any of data type.Plz explain with example so that i can understand better
How to create a pointer to function in C language?
Dear,
Consider the following syntax of a function:
return_type function_name(datatype of arguement1,datatype of arguement2,.....)
So the pointer declaration would be:
return_type (*pointer_name)(datatype of arguement1,datatype of arguement2,.....)=defaultvalue;
So if we have a function as
int sum(int)
then a pointer able to store its address would be:
int (*ptr)(int);
To set ptr a default vale to NULL we can also declare it as:
int (*ptr)(int)=NULL;
In order to store address of the function we may write
ptr=sum;
Also if function is:
int *show(int *,char *,float **)
then ptr which can hold its address would be
int *(*ptr)(int *,char *,float **)=NULL;
OM NAMAH SHIVAY
Reply:if u wanna create a pointer with variable a use*a it will work
Reply:Just design one. It's more custom and easier. But if you don't have time to make one, go to this site:
http://pw1.netcom.com/~tjensen/ptr/point...
Good luck and cheers!
=)
Reply:This page should help.
http://www.newty.de/fpt/index.html
This was the first result I got when I Googled for "function pointer C". This just goes to prove how easy it is to search the net, and how unnecessary so many questions on Y!Answers are.
Reply:Use *ptr = ptr
land survey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment