This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

the func pointer used in the keil.

Dear all,

Who can help me the following question.

I had wrote three routine,such as:

void p1(void)
{
printf("1!\n");
}

void p2(void)
{
printf("2!\n");
}

void p3(void)
{
printf("3!\n");
}

than I new a pointer and a func arrary for these func,

void (code* pfun1)(void); //the pointer

void (code* cFunc[])(void) = //the array
{
p1,
p2,
p3
};

then call the routine with the pointer in main routine,


main()
{
while(1)
{
unsigned char i;
for(i = 0 ; i < 3 ; i++)
(*(cFunc+i))();
}
}

but the result is only execute the p1 routine,Then I think the i should be change to another type same as cFunc,So I had change the i data type as
--> void (code*)(void) i;
but the result is still error,who can told me how can let the routine execute corretly?

Thanks a lot.

0