By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

can anybody telle me this

P: n/a
i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??

Jun 17 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
c beginner skrev:
i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??
this may do:
http://publications.gbdirect.co.uk/c..._pointers.html
Jun 17 '07 #2

P: n/a
c beginner said:
i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??
What is it that is confusing you about pointers to functions?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 17 '07 #3

P: n/a
On Jun 17, 9:13 pm, c beginner <saheb1...@gmail.comwrote:
i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??
function pointer holds address of function that you have specified.
as you call function by pointer.

fp = foo(int,int);
so you can call as
*fp(1,2);

depending on requrement you just assign address of function to
pointer.
it will get executed through function pointer call.
Jun 18 '07 #4

P: n/a
On Mon, 18 Jun 2007 08:39:50 -0000, Sachin <sv****@gmail.comwrote:
>On Jun 17, 9:13 pm, c beginner <saheb1...@gmail.comwrote:
>i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??

function pointer holds address of function that you have specified.
as you call function by pointer.

fp = foo(int,int);
so you can call as
*fp(1,2);
Don't anyone take any of this code as legitimate c.
>
depending on requrement you just assign address of function to
pointer.
it will get executed through function pointer call.

Remove del for email
Jun 18 '07 #5

P: n/a
Sachin wrote:
On Jun 17, 9:13 pm, c beginner <saheb1...@gmail.comwrote:
>i have a confusion about pointer to functions.can anybody help me to
overcome my confusion??

function pointer holds address of function that you have specified.
as you call function by pointer.

fp = foo(int,int);
so you can call as
*fp(1,2);

depending on requrement you just assign address of function to
pointer.
it will get executed through function pointer call.

Not quite like that. Let's define the function foo..

int foo(int a, int b) {
return a + b;
}

Now let's define a pointer to function returning int and taking two int
arguments.

int (*fp)(int, int);

Now initialize fp..

fp = foo;

Now you call it through the pointer with..

int x;
x = fp(1, 2);

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Jun 18 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.