Original Post
Hello all,
How do I go about making a function that I can pass a pointer to of another function. I think this kind of thing is called callback functions. I dunno though.
The kind of function I am trying to create would be something like the ''CreateThread" fuction, where you have to pass a pointer to a function that later will be called.
How do I go about writing a function like this?
So far I have:
//------------CODE------------
typedef void (*Function)();
Function myFunction;
void runFunction(Function pFunction){
myFunction = pFunction;
(myFunction)();
}
void TheFunctionToRun(){
ShowMessage("Hello");
}
void main(){
runFunction(&TheFunctionToRun);
}
//----------------------------
I know i should simply fun "pFunction" streight away instead of assigning it to a variable, But that is part of the requirement of the function.
That code does not work, and I''m not suprised as I have never tried to do anything like this before. Can anyone enlighten me as to how I should fix this problem?
BTW, I have seen posts in these forums with sections that have sections for code, and there is syntax highlighting. How do I do this?