|
Re: An Example Please :)
[Re: 3run]
#411501
11/17/12 14:24
11/17/12 14:24
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
...or do you need something like this:
#include <acknex.h>
void * void_pointer(); // create a pointer to a 'void'
void test_function()
{
printf("test");
}
void main()
{
void_pointer = test_function; // the pointer should point to 'test_function'
void_pointer(); // call the void the pointer points to
}
POTATO-MAN saves the day! - Random
|
|
|
Re: An Example Please :)
[Re: Kartoffel]
#411502
11/17/12 14:27
11/17/12 14:27
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
oh you were some seconds faster. heres the fixed version of your code 
#include <acknex.h>
int * p(); // <-- needs ()
int _function()
{
error("works now.");
}
void main()
{
p = _function; // <-- without &
p();
}
...and next time please use [ code] and [ /code] to make your code better readable 
Last edited by Kartoffel; 11/17/12 14:28.
POTATO-MAN saves the day! - Random
|
|
|
Re: An Example Please :)
[Re: Kartoffel]
#411506
11/17/12 14:41
11/17/12 14:41
|
Joined: Nov 2011
Posts: 139 India
Yashas
OP
Member
|
OP
Member
Joined: Nov 2011
Posts: 139
India
|
How do I take a function as a function parameter ,heres what I have done but causes an error
void SetTimer (int * p,int time,void * func)
{
while(*p > 0)
{
wait((time * -1));
}
if(func) { func(); }
}
It does not work, why??
|
|
|
Re: An Example Please :)
[Re: Kartoffel]
#411510
11/17/12 14:51
11/17/12 14:51
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
I would like to point out that none of Kartoffels declared return types matches with what the actual function returns.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: An Example Please :)
[Re: WretchedSid]
#411529
11/17/12 15:13
11/17/12 15:13
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
well would you then please consider about telling us how to do it right? -.-
Last edited by Kartoffel; 11/17/12 15:13.
POTATO-MAN saves the day! - Random
|
|
|
Re: An Example Please :)
[Re: Kartoffel]
#411531
11/17/12 15:15
11/17/12 15:15
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
It's "void temp_void();" temp_void returns void not a void pointer.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|