Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define STACK_SIZE 10
- void addFunc(void (*)(void));
- void eval(void);
- void test(void);
- unsigned int cFunc = 0;
- void (*tFunc[STACK_SIZE])(void);
- void addFunc(void (*pfunc)(void))
- {
- if (cFunc == STACK_SIZE)
- {
- fprintf(stderr, "stack overflow\n");
- return;
- }
- tFunc[cFunc] = pfunc;
- cFunc++;
- }
- void eval()
- {
- int i;
- for (i = 0; i < STACK_SIZE; i++)
- tFunc[i]();
- }
- void test()
- {
- static int tmp = 0;
- printf("%d\n", tmp++);
- }
- int main(int argc, char *argv[])
- {
- int i;
- for (i = 0; i < 15; i++)
- addFunc(test);
- eval();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement