🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3509

Re: function pointers (in C)

#3509
From: orlov
Date: Wed, 07 Oct 1992 03:22
36 lines
1591 bytes
In article <1992Oct5.222801.12917@u.washington.edu>, goble@hardy.u.washington.edu (Brian Goble) writes:
> I am not familiar with using function pointers, please help if you can:
> 
> 
> I want to be able to pass a function pointer to another function, have that
> function store the function pointer in a structure field, and later,
> call that function from the structure field.  The function pointer is to
> a function that returns an "int" and takes a "LPWORD" as it's only arg.
>

Hi Brian!

I think this example will help you:

typedef     float (*FPTR)(char);

This defines a new type FPTR. Objects of this type point to a function
that returns a FLOAT value and has one CHAR argument.

After that, you can write (for example):

FPTR        p0;
float       k;

...

p0=user_function;
k=(*p0)('a');			/* Calls user_function via the pointer */


			Hope it can help you,
							D.S.

-------------------------------------------------------------------------------
		"I'm from the land of Russia where the Shadows lie!"
-------------------------------------------------------------------------------
Technical Details
Message-ID: <1992Oct6.184246.1@mars.ibioc.serpukhov.su>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!fuug!kiae!uranus!mars.ibioc.serpukhov.su!orlov
References: <1992Oct5.222801.12917@u.washington.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!fuug!kiae!uranus!mars.ibioc.serpukhov.su!orlov
From: orlov@mars.ibioc.serpukhov.su
Subject: Re: function pointers (in C)
Message-ID: <1992Oct6.184246.1@mars.ibioc.serpukhov.su>
Lines: 37
Sender: news@uranus.ibioc.serpukhov.su (USENET News System)
Organization: Institute of Cell Biophysics
References: <1992Oct5.222801.12917@u.washington.edu>
Date: Wed, 7 Oct 1992 03:22:46 GMT