473,326 Members | 2,102 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,326 software developers and data experts.

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 1602
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("Handling 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**********************@j33g2000cwa.googlegroups .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
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...
3
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...
2
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...
5
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...
10
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
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 =...
7
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
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...
19
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.