![](wink.gif)
Arrays of variable size
Hey i want to load in my games map from a text file, its an old text rpg. Anyway, i planed to hold the map size at the top of the file but I can''t figure out how to set an array to a variable size, ie the mapsize thats carried in the variable at the top of the file. Any help will be greatly appreciated
Cheers. Armed and Hammered
![](wink.gif)
Simple way:
Assuming you ant an array of ints...
int* GameMap = (int*)malloc(sizeof(int) * MAP_SIZE_X * MAP_SIZE_Y);
Assuming you ant an array of ints...
int* GameMap = (int*)malloc(sizeof(int) * MAP_SIZE_X * MAP_SIZE_Y);
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Don''t forget to free it when you''re done (look up free, delete, as well as new and malloc (already mentions)). Dynamic Allocation is key to programming a lot of things
.
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
![](smile.gif)
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement