Hey, me again, still on Winblows.
I'm trying to, in C, have a pointer to a function in a structure.
So, for instance, struct object has a variable defined like so;
and I would set this with a pointer to a function, then try and call the func like so;
Code:
items[1].callback();
The compiler complained about not being able to find the func, and then I fixed that, now it produces no errors, but the function doesn't print anything like it's supposed to.
Here's the code I have so far;
here's the item struct;
Code:
typedef struct item{
int location;
char name[20],desc[20];
void *callback;
} item;
Here's what configs the item;
Code:
void configitem(struct item *item,char name[20],char desc[50],int location,void *callback){
memcpy(item->desc, desc, strlen(desc));
memcpy(item->name, name, strlen(name));
item->location=location;
item->callback = callback;
}
and I call that like so;
Code:
configitem(&items[1],"Gun","A Gun",1,&poodle);
and here's how I'm calling the func;
Also, when I put parentheses around the callback that I'm trying to use, it says 'term does not evaluate to function'