Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Saving File Help

4: Adsense

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   

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


#2 bradbobak   Members   

1802
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   

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.