Jump to content
  • Advertisement
Sign in to follow this  
levijgraham

Saving File Help

This topic is 2495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello im trying to save the chuncks of my map in in the folder called level each chunk is supposed to be represented by a diffrent file but i cant seem to figure out how to get what number my loop is on to save in with my file name so i end up getting files called all sorts of names that i dont want.


void Map::Save()
{
for(int loop = 0; loop < Map::AmountOfChuncks;loop++)
{
for(int loop2 = 0; loop2 < Map::AmountOfChuncks;loop2++)
{
ofstream file( "Level/Chunck"+loop+"_"+loop2".Data" );
Map::GenerateChunck();
for(int loop3 = 0; loop3 < Map::AmountOfChuncks;loop3++)
{
for(int loop4 = 0; loop4 < Map::AmountOfChuncks;loop4++)
{
file << Map::Data[loop3][loop4];
}
}
file.close();
}
}}

Share this post


Link to post
Share on other sites
Advertisement
You cannot concatenate c-strings and integers in that way.

One way to do it is:


std::stringstream ss;

ss << "Level/Chunk" << loop1 << "_" << loop2;

std::ofstream file(ss.str().c_str());

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!