| ??? 11/21/07 16:57 Read: times |
#147313 - Adjust declaration Responding to: ???'s previous message |
Hey Stefan, this code did compile here for me but I should have had a complete declaration of the function pointers. Try changing all 3 of your function pointer declarations to the following style:
void (*functionptr)(void); Get rid of the "const" qualifier for all these function pointers as well, they serve no purpose. Your code should look like this.
#define __MAIN_C__
const char mychar1[6]="ABCDEF";
const char *mycharptr;
int mymode;
void xgetstr1(void);
void xgetstr2(void);
typedef struct
{int mode;
void (*funcptr1)(void);
void (*funcptr2)(void);
} myoneset;
void xgetstr1(void){ mycharptr=&mychar1[0];}
void xgetstr2(void){ mycharptr=&mychar1[1];}
myoneset listofsets[2] =
{{1,&xgetstr1,&xgetstr2}, {3,&xgetstr2,&xgetstr1}};
int main (void)
{
void (*myfuncptr)(void);
int i ;
mycharptr=&mychar1[0];
mycharptr=&mychar1[2];
myfuncptr=&xgetstr1;
myfuncptr=listofsets[0].funcptr1;
myfuncptr=listofsets[1].funcptr2;
myfuncptr=0;
mymode=2;
for (i=0;i<2;i++)
{
if (listofsets[0].mode==mymode)
myfuncptr=listofsets[1].funcptr2;
}
myfuncptr(); // Call like this
return(0);
}
Before the return I added the call of the function. |
| Topic | Author | Date |
| Sequence of learning 8051, asm and C | 01/01/70 00:00 | |
| 2 Issues | 01/01/70 00:00 | |
| my wrong path | 01/01/70 00:00 | |
| OT, but | 01/01/70 00:00 | |
| OT - error message | 01/01/70 00:00 | |
| Use the tags | 01/01/70 00:00 | |
| single-character const | 01/01/70 00:00 | |
| QED? | 01/01/70 00:00 | |
| As Erik suggests | 01/01/70 00:00 | |
| Just learning - too luxury. | 01/01/70 00:00 | |
| how can that be "too luxorious" | 01/01/70 00:00 | |
| Foolish builder? | 01/01/70 00:00 | |
| pointer to a const | 01/01/70 00:00 | |
| True, but... | 01/01/70 00:00 | |
| Explaining | 01/01/70 00:00 | |
| helpfull ,thanks, but.. | 01/01/70 00:00 | |
| Declaration | 01/01/70 00:00 | |
| thanks | 01/01/70 00:00 | |
| Adjust declaration | 01/01/70 00:00 | |
thanks again | 01/01/70 00:00 | |
| const | 01/01/70 00:00 | |
| no wrong path | 01/01/70 00:00 | |
| learning C | 01/01/70 00:00 | |
| Freebies | 01/01/70 00:00 | |
| Erik is right | 01/01/70 00:00 | |
| not necessary | 01/01/70 00:00 | |
| You\'re skipping the most important step ... | 01/01/70 00:00 |



