I wrote some code:). I don't know make it work. It work when I use array but it doesn't work when I use array of structs. In my program I use library function to take data from inside database and it look like that:
int opfGetAll( void *opf,const char *info, const char *name, void *parms )
opf - pointer to db
info - the info type
name - name of parameter
parm - the array output, this must be of the correct type
int main()
{
struct data
{
int intVal;
float floatVal;
double doubleVal;
};
//struct data *iform1_tab = malloc(sizeof(struct data)*number_locs);
float *iform1_tab = malloc(sizeof(float)*number_locs);
if(iform1 ==2 )//FLOAT
{
//opfGetAll(opf,type1,attr_inp1, &iform1_tab[0].floatVal);//don't take all data, it fill half of it and the rest is 0 or rubbish
opfGetAll(opf,type1,attr_inp1, iform1_tab );//this version fill all array
}
}
struct datais overwriten (you loose the array and introduce a memory leak) in the second call tomallociform1inif(iform1 ==2 )come from?opfGetAllknow ifvoid *parmspoints to an array ofstructor an array offloatand how big your array is? If you pass&iform1_tab[0].floatVal, it cannot know how to findiform1_tab[1].floatValetc.