Jump to content

  • Log In with Google      Sign In   
  • Create Account

Saving File Help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 levijgraham   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 December 2011 - 04:24 AM

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();
		}
	}}


Sponsor:

#2 bradbobak   Members   -  Reputation: 1150

Like
1Likes
Like

Posted 16 December 2011 - 04:38 AM

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());


#3 levijgraham   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 December 2011 - 04:46 AM

amazing thank u i couldnt figure that out for the life of me :P




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS