473,609 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

querry regarding function pointer

hi
Please someone give a real time implimentation of a function pointer.
where exactly we need a function pointer very much . if it is in terms
of code i will be happy enough .
thanks in advance

Mar 16 '06 #1
7 1619
Lalatendu Das wrote:
hi
Please someone give a real time implimentation of a function pointer.
where exactly we need a function pointer very much . if it is in terms
of code i will be happy enough .
thanks in advance


#include <stdio.h>
#include <signal.h>
void sigterm_handler (int sig)
{
printf("Handlin g signal %d", sig);
}
int main(void)
{
signal(SIGTERM, sigterm_handler );

raise(SIGTERM);

return 0;
}
--
==============
Not a pedant
==============
Mar 16 '06 #2
Lalatendu Das wrote:
Please someone give a real time implimentation of a function pointer.
I guess you mean "real world"...
where exactly we need a function pointer very much.
It really depends on your application. Simulating polymorphism is one.
if it is in terms of code i will be happy enough.


#include <math.h>
#include <stdio.h>

#define PI 3.14159

double (*trig)(double) ;

int main(void)
{
trig = sin;
printf("sin(PI) = %f\n", (*trig)(PI/2.0));

trig = cos;
printf("cos(PI) = %f\n", (*trig)(PI/2.0));

return 0;
}

--
BR, Vladimir

Mar 16 '06 #3
Lalatendu Das said:
hi
Please someone give a real time implimentation of a function pointer.
where exactly we need a function pointer very much . if it is in terms
of code i will be happy enough .


You can find good examples on page 118 of "The C Programming Language", 2nd
edition, by Kernighan and Ritchie, or on pages 146-147 of "C - A Reference
Manual", 4th edition, by Harbison and Steele.
--
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)
Mar 16 '06 #4
thanks for all your answers .They are really good. But specifically
from the point veiw of protocol stack developement is there any
instance which make use of pointer very needy andbest as well

Mar 16 '06 #5
Yes, of course.
Mar 16 '06 #6
On Thursday 16 March 2006 15:45, osmium opined (in
<47************ @individual.net >):
Yes, of course.


But if I tell him, I'll have to kill him.

--
BR, Vladimir

It's amazing how much "mature wisdom" resembles being too tired.

Mar 16 '06 #7
On Thursday 16 March 2006 15:24, Lalatendu Das opined (in
<11************ **********@j33g 2000cwa.googleg roups.com>):
thanks for all your answers .They are really good. But specifically
from the point veiw of protocol stack developement is there any
instance which make use of pointer very needy andbest as well


Quote context, otherwise your posts make little sense. For example, it's
an accident that I know you mean "function pointers" not just any
pointers. Read and heed: <http://cfaj.freeshell. org/google/>. This
one <http://clc-wiki.net/wiki/Introduction_to _comp.lang.c> is also
useful.

Back to your question: yes, there is a perfectly good place for function
pointers in protocol stack development.

<OT>
For example: programming a sequence of tasks for the DSP to perform in
lower parts of protocol stack of a mobile phone.
</OT>
--
BR, Vladimir

Trust in Allah, but tie your camel.
-- Arabian proverb

Mar 16 '06 #8

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

Similar topics

2
3190
by: Eric Kincl | last post by:
Hello, I have an array of data in PHP. I would like to insert each member of the array into it's own row in SQL. The array is of variable length, so it would have to be dynamic code. How would I go about this? Would I stick the SQL querry generation and actual querry into a while loop? This would generate a lot of traffic between the SQL server and the PHP script. The arrays are each over 1000 members long, however, this is an rare...
3
1309
by: AlesD | last post by:
Hello, maybe my question is stupid, but... I have function/algorithm which operates on sequence holding objects of type T. The problem is that I do not know (at the declaration time) which sequence (vector<T> or list<T>) will be used. class element_t { void some_method(void);
2
1269
by: gurpreet | last post by:
Hi this is gurpreet, I know this is a very simple question but still I want to clear some doubts. What happens when we compile and link a c-program? I hope aquite a lot of responses to my querry. BYE! BYE!
5
1571
by: ranjeet.gupta | last post by:
Dear All As I was going through the Recent replies on the realloc(), I got some question and my annalysis on that, so regarding on these please guide me where I fail on the theoritical and practical Knowledge. I am not able to read all the thread in the replies as due to some problem in the web server. Point 1.
10
1672
by: Maulik Thaker | last post by:
Hi ppl, I have a querry based on ID. Suppose if i have got two primary keys (ID) and one foreign key (IDREF) in the same attribute, is there a way to use them. For example :
7
1875
by: ravips | last post by:
I have a map<char *,int it does not work consistently. I have used similar sort of implementation as below: map<char *,intm1; map<char *,int>::iterator i; m1 = 31; m1 = 28; m1 = 31; m1 = 30;
7
1386
by: mohan | last post by:
Hi i am new to this group.Kindly send me the C language code that can open and play a player(mp3 etc)
2
3255
by: venkat | last post by:
Hi, i came across restrict qualifier while looking the code. I haven't able to understand what does this do?. Can some one help me how does this makes the things restrict to an specified objects. It will be good, if explained with example. Appriciate your help in this regard. Thanks,
19
2035
by: bowlderyu | last post by:
Hello, all. If a struct contains a character strings, there are two methods to define the struct, one by character array, another by character pointer. E.g, //Program for struct includeing character strings, test1.c #include <stdio.h> #define LEN 20 struct info {
0
8113
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
8557
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...
0
8512
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8378
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...
1
6047
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
4007
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
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2517
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1637
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.