473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
6 17032
"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
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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ¤ Alias | last post by:
I have a function named getID3info (lvwDiscInfo.SelectedItem). What is the difference between getID3info (lvwDiscInfo.SelectedItem) and Call getID3info(lvwDiscInfo.SelectedItem) ?
1
by: jack | last post by:
Hi all, Suppose I have a routine to find the maximum of any *univariate* function f in the interval : double f(double x); double findmax(double (*func)(double), double a, double b); Now I...
18
by: steve | last post by:
I'm trying to create a structure of three pointers to doubles. For which I have: typedef struct { double *lst_t, *lst_vc, *lst_ic; } last_values; I then need to allocate space for...
4
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb...
42
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
8
by: solarin | last post by:
Hi all. I'm writting a logger class to write all the debug/info/warning/error messages in a file. Every time a class needs to send any message, should send a code (int) and a message (string)....
4
by: craig | last post by:
During construction of an object "parent", if you create a subobject that stores a pointer to the parent (through the "this" pointer), will that pointer be valid when the subobject is later called?...
3
by: Chen ShuSheng | last post by:
HI, I am now study a segment of codes: ------------------------ printf("%p\t",fp); /*add by me*/ fseek(fp, 0L, SEEK_END); /* go to end of file */ printf("%p\t",fp); ...
20
by: chutsu | last post by:
I'm trying to compare between pointer and integer in an "IF" statement how do I make this work? if(patient.id != NULL){ } Thanks Chris
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.