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

diffrence between "function pointer" and "pointer to a function"

P: n/a
Hi people,
i am new to this group,this is my first query,

friends i want to know the difference between "function pointer" and
"pointer to a function" in c lang, so friends please send the answers
as early as possible, thanking u all
vijay

Dec 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"murgan" <vi***********@gmail.com> writes:
friends i want to know the difference between "function pointer" and
"pointer to a function" in c lang, so friends please send the answers
as early as possible, thanking u all


As far as I know, they're just two different ways of saying the same
thing.

Please use proper capitalization, and avoid abbreviations like "u" for
"you"; they make your text more difficult to read.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 19 '05 #2

P: n/a
function pointer means function returning pointer.
1)int * add(int x,int y)
{
int z;
z = x+y;
return(&z);
}
we may put a function call as follows
int *a;
a = add(x,y);

2)pointer to a function is a function whic in turn points to another
function.
like
int add();
int (*addi)();
addi =&add;
then (*addi)() represents add();

this is the difference b'wn function pointer and pointer to a function.

Dec 19 '05 #3

P: n/a
ki************@yahoo.com said:
function pointer means function returning pointer.
No, it doesn't.
2)pointer to a function is a function whic in turn points to another
function.
No, it isn't.
this is the difference b'wn function pointer and pointer to a function.


No, it isn't.

A pointer to a function is a pointer that points to a function. A function
pointer is a pointer that either has an indeterminate value, or has a null
pointer value, or points to a function.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 19 '05 #4

P: n/a
ki************@yahoo.com wrote:

Please provide context. See http://cfaj.freeshell.org/google/
function pointer means function returning pointer.
No, when people say function pointer they normally mean a pointer to a
function. At least, that has been the case every time I've seen the term
used (and I've both seen and used it a fair bit) it has meant a pointer
to a function.
1)int * add(int x,int y)
This I ouw call a function returning a pointer to in, or if I'm not
bothered about the type a function returning a pointer.
{
int z;
z = x+y;
return(&z);
}
we may put a function call as follows
int *a;
a = add(x,y);

2)pointer to a function is a function whic in turn points to another
function.
like
int add();
int (*addi)();
addi =&add;
You don't need the & although it does no harm.
then (*addi)() represents add();

this is the difference b'wn function pointer and pointer to a function.


Maybe the way you use the terms, but that is not what I've come across
in far too many years of programming in many languages.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 19 '05 #5

P: n/a

murgan wrote:
Hi people,
i am new to this group,this is my first query,

friends i want to know the difference between "function pointer" and
"pointer to a function" in c lang, so friends please send the answers
as early as possible, thanking u all


They're just two different ways of describing the same thing as far as
I know.

Dec 19 '05 #6

P: n/a
Richard Heathfield wrote:
ki************@yahoo.com said:
function pointer means function returning pointer.


No, it doesn't.

2)pointer to a function is a function whic in turn points to another
function.


No, it isn't.


He, he, when I read kishore's response, I swear there was a line saying
<enable twisted homework response mode>. Maybe that didn't come though
on your copy. ;-)

--
Thad

Dec 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.