473,396 Members | 2,147 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.

What is function pointer?

hi friend,

what is function pointer how it is useful?
plz help me.

Nov 15 '05 #1
10 1431
sabarish wrote:
what is function pointer how it is useful?


Search the web. A Google search for 'C "function pointer"' gives instant
results.

S.
Nov 15 '05 #2
"sabarish" <su******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
hi friend,

what is function pointer
A pointer object or value which contains the address
of a function.
how it is useful?


If one doesn't know what it is, not at all.

Now a question for you:
"What is a textbook, and how is it useful?"

-Mike
Nov 15 '05 #3
"sabarish" writes:
what is function pointer how it is useful?


It is a pointer that points to a function rather to a variable which is the
more common case.

A nice understandable usage is in the standard library, qsort which is geek
speak for quick sort. Think of three functions, main, qsort and compare.
main contains a pointer to compare which will tell qsort *how* to compare.
Comparing doubles is different that comparing ints, for example. so main
calls qsort and passes the pointer to compare (a function pointer) in the
argument list. This means that qsort can, in turn, use (call) the proper
compare function.
Nov 15 '05 #4
sabarish wrote:

hi friend,

what is function pointer how it is useful?
plz help me.


The only thing that you can do with the name of a function
in a correct C program, is derive a pointer from it,
either through the address operator &, or by conversion.

--
pete
Nov 15 '05 #5

"pete" <pf*****@mindspring.com> wrote in message
news:43***********@mindspring.com...
sabarish wrote:

hi friend,

what is function pointer how it is useful?
plz help me.


The only thing that you can do with the name of a function
in a correct C program, is derive a pointer from it,
either through the address operator &, or by conversion.


The *only* thing?

What about calling the function? :-)

-Mike
Nov 15 '05 #6
sabarish wrote:
hi friend,

what is function pointer how it is useful?
plz help me.


I suggest you just post the complete assignment together with your
instructors email address so we can send the answers direct.

Alternatively, at least attempt to find the answers in your text book.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #7
"osmium" <r1********@comcast.net> writes:
"sabarish" writes:
what is function pointer how it is useful?


It is a pointer that points to a function rather to a variable which is the
more common case.

A nice understandable usage is in the standard library, qsort which is geek
speak for quick sort.

[snip]

Going off on a tangent ...

Quicksort is a specific recursive sorting algorithm. The name "qsort"
probably was originally an abbreviation for "quicksort" (back in the
days when some systems had severe limits on the lengths of external
names), but there's no implication in the standard that it uses any
particular algorithm.

--
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.
Nov 15 '05 #8
"Mike Wahler" <mk******@mkwahler.net> writes:
"pete" <pf*****@mindspring.com> wrote in message
news:43***********@mindspring.com...
sabarish wrote:

hi friend,

what is function pointer how it is useful?
plz help me.


The only thing that you can do with the name of a function
in a correct C program, is derive a pointer from it,
either through the address operator &, or by conversion.


The *only* thing?

What about calling the function? :-)


All function calls take place via function pointers. See the
standard:

6.5.2.2 Function calls
Constraints
1 The expression that denotes the called function77) shall have
type pointer to function returning void or returning an
object type other than an array type.

....

77) Most often, this is the result of converting an
identifier that is a function designator.

--
"For those who want to translate C to Pascal, it may be that a lobotomy
serves your needs better." --M. Ambuhl

"Here are the steps to create a C-to-Turbo-Pascal translator..." --H. Schildt
Nov 15 '05 #9
"Mike Wahler" <mk******@mkwahler.net> writes:
"pete" <pf*****@mindspring.com> wrote in message
news:43***********@mindspring.com...
sabarish wrote:

hi friend,

what is function pointer how it is useful?
plz help me.


The only thing that you can do with the name of a function
in a correct C program, is derive a pointer from it,
either through the address operator &, or by conversion.


The *only* thing?

What about calling the function? :-)


The function call operator requires a function pointer. Given a
function name, you can't call the function without converting it to a
pointer, usually implicitly.

--
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.
Nov 15 '05 #10
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@benpfaff.org...
"Mike Wahler" <mk******@mkwahler.net> writes:
"pete" <pf*****@mindspring.com> wrote in message
news:43***********@mindspring.com...
The only thing that you can do with the name of a function
in a correct C program, is derive a pointer from it,
either through the address operator &, or by conversion.


The *only* thing?

What about calling the function? :-)


All function calls take place via function pointers. See the
standard:

6.5.2.2 Function calls
Constraints
1 The expression that denotes the called function77) shall have
type pointer to function returning void or returning an
object type other than an array type.

...

77) Most often, this is the result of converting an
identifier that is a function designator.


I stand educated. Thanks.

-Mike
Nov 15 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lawrence | last post by:
I posted before, but have now narrowed my problem down to this method. At the start of the method, I test to make sure that I have a resource, a pointer to data returned from a database. This test...
3
by: Guybrush Threepwood | last post by:
double ** matrix; struct data_point { float x,y,z; float nx,ny,nz; float value; };
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
3
by: Sathyaish | last post by:
I wanted to practice some Linked List stuff, so I set out to create a linked list. The plan was to create the following: (1) A linked list class in Visual Basic (2) A non-class based linked list...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
5
by: Omats.Z | last post by:
what is meaning os "char **option meet"? I get a function like this: __________________________________ int getchoice(char *greet, char *choices) { int chosen = 0; int selected; char **option;...
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
36
by: Pat | last post by:
Hi, I've run into a strange problem, but one that seems like it might be fairly common. I have a single base class, from which several other classes are derived. To keep the example simple,...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.