Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Two questions about pointers...
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.