Article View: comp.os.msdos.programmer
Article #3497function pointers (in C)
From: Brian Goble
Date: Mon, 05 Oct 1992 22:28
Date: Mon, 05 Oct 1992 22:28
49 lines
1522 bytes
1522 bytes
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.
A #define would be nice too...
So, I want:
#define LPFUNC ? // prototype is: int Foo(LPWORD);
typedef MyStruct {
LPFUNC func; // function pointer: int Foo(LPWORD);
int count;
};
void StoreFunc(func) // store the given function
LPFUNC func;
{
A.func = func;
return;
}
void CallFunc(void)
{
int i;
WORD word;
i = A.func((LPWORD)&word); // call the function from the structure
return;
}
Thanx for any help!!!
-Brian Goble
--
==)------------
Brian Goble | goble@hardy.u.washington.edu
"Finishing a close second means you didn't win."
------------(==
Technical Details
Message-ID:
<1992Oct5.222801.12917@u.washington.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!news.u.washington.edu!hardy.u.washington.edu!gobleShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!news.u.washington.edu!hardy.u.washington.edu!goble From: goble@hardy.u.washington.edu (Brian Goble) Newsgroups: comp.os.msdos.programmer Subject: function pointers (in C) Message-ID: <1992Oct5.222801.12917@u.washington.edu> Date: 5 Oct 92 22:28:01 GMT Article-I.D.: u.1992Oct5.222801.12917 Sender: news@u.washington.edu (USENET News System) Organization: University of Washington Lines: 49