Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > diffrence between "function pointer" and "pointer to a function"

Reply
Thread Tools

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

 
 
murgan
Guest
Posts: n/a
 
      12-19-2005
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

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      12-19-2005
"murgan" <(E-Mail Removed)> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
 
 
 
kishore_mca330@yahoo.com
Guest
Posts: n/a
 
      12-19-2005
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.

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-19-2005
(E-Mail Removed) 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)
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      12-19-2005
(E-Mail Removed) 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.
 
Reply With Quote
 
John Bode
Guest
Posts: n/a
 
      12-19-2005

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.

 
Reply With Quote
 
Thad Smith
Guest
Posts: n/a
 
      12-21-2005
Richard Heathfield wrote:

> (E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it because of diffrence between bcc32 and gcc? jigsaw C Programming 4 05-08-2006 03:30 PM
Diffrence between application server and web server ITpro Java 2 10-29-2005 11:17 AM
Diffrence between ++i and i++ Luai C Programming 12 05-07-2004 09:26 PM
diffrence between signal, variable and wire, register mohammed rafi VHDL 3 05-07-2004 05:56 PM
diffrence between wire (in verilog) and signal (in vhdl) mohammed rafi VHDL 1 05-06-2004 04:21 PM



Advertisments