473,770 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is function pointer?

hi friend,

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

Nov 15 '05 #1
10 1459
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.goo glegroups.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*****@mindsp ring.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********@com cast.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_Keit h) 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******@mkwah ler.net> writes:
"pete" <pf*****@mindsp ring.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******@mkwah ler.net> writes:
"pete" <pf*****@mindsp ring.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_Keit h) 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

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

Similar topics

5
2035
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 is coming back true, so the next line runs, which attempts to get the next row from the dataset. This brings back nothing. On the queries I'm running right now, the first row will be fetched, but then no further rows. If I expect 20 rows back, I...
3
1380
by: Guybrush Threepwood | last post by:
double ** matrix; struct data_point { float x,y,z; float nx,ny,nz; float value; };
140
7906
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
5300
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
2078
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 using functions in C (3) A linked list class in C++ I started with Visual Basic and I wrote an IList interface that I wanted my list to implement. When I had started, somehow I thought this time, I'd first use a collection as the ingredient,...
51
4564
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 there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of storage bits. It gives the meaning of the data stored in memory. If we say that the object a is an
5
14118
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; // what is this line mean? do { printf("Choice: %s\n", greet);
4
6697
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 = "Content-Type: text/html\r\n"; Why is the second const needed and what does it do? Thanks
36
2592
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, the base class is "Animal" and the derived classes are "Cat," "Dog," and "Horse." The base class has a pure virtual method:
11
3361
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 ways of passing an array. In the following code, fun1(int a1) - same as fun1(int* a1) - where both are of the type passed by reference. Inside this function, another pointer a1 is created whose address &a1 is different from that of the passed...
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.