Hi ,
can anybody tell me how to put functions in an array??
like this...
void f1(){
}
void f2(){
}
arr[2]={f1(),f2()}
i want to simulate some cpu scheduling algorithms in a arduino board. Anybody have an idea about it???
thanks.
Hi ,
can anybody tell me how to put functions in an array??
like this...
void f1(){
}
void f2(){
}
arr[2]={f1(),f2()}
i want to simulate some cpu scheduling algorithms in a arduino board. Anybody have an idea about it???
thanks.
Every time I do this I get it wrong and have to look at old code, but I think this is one correct way to do it
typedef void (*voidFuncPtr) (void);
void func1 (void) {}
void func2 (void) {}
void func3 (void) {}
voidFuncPtr myFuncArray[] = {func1, func2, func3};
void loop () {
(myFuncArray[1])(); // call func2
}
Note that "voidFuncPtr" is just a name I made up, and also the funcs don't have to be void with no parameters.
For example
typedef int (*funcPtr) (byte *, long);
It works...thank you......
Have you seen my Prior post on dispatching timer controlled Events?
https://forum.arduino.cc/index.php?topic=377068.msg2599752#msg2599752