OK, I have figured out the basics of using pointers, but now I have to figure out two more thigns to be able to use them properly. One is accessing a pointer in a pointer, and the other is setting the different values of a structure pointed to by a pointer. First, let me show you my structures:
bool solid, pushable;
char name, target;
Now how would I properly allocate memory for LEVELINFO structures, such as the demo, map? Here is what I have toyed with:
brush.plist = (POLYGON *)malloc(sizeof(POLYGON));
//Above works aok!
map.olist = (OBJECT *)malloc(sizeof(OBJECT));
map.olist.plist = (POLYGON *)malloc(sizeof(POLYGON));
//The problems are how to allocate ram for the pointer in a pointer
OK, that aside, say I wanted to set or retrieve a var in one of the many OBJECT structs. Could I (after creating, say, five objects via pointers) access them via brush.polygon[x].x? If not, how exactly would i reference them individually? Thanks in advance for the help.
0 · ·