I have a struct:
Code:
typedef struct command
{
char *name; //command name
char mode; //0-read, 1- read/write
int minval;
int maxval;
void (*fp) (int com_num); //pointer to function
void *vp; //pointer to variable
}command;
command commands[] = {
{"imax1", 1, 0, 10000, GetSetImax, &max_current1},
{"imax2", 1, 0, 10000, GetSetImax, &max_current2},
};
I can read from variable:
Code:
UsartSendInt( (int)commands[com_num].vp );
But can not write to:
Code:
(int *)(commands[com_num].vp) = 10;
What I'm doing wrong?