Jump to content
  • Advertisement
Sign in to follow this  
sipickles

building filenames on the fly

This topic is 4931 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

Hi, I am a little puzzled on how to build filenames as a function runs. I am trying to pass a base filename to a function, then load filename_1, filename_2 etc
Cworld::Cworld( LPDIRECT3DDEVICE9 _Device, CHAR* filename, int _numSectors )
{
	m_lpDevice	= _Device;
	m_iNumSectors	= _numSectors;

	for ( int i = 0; i < m_iNumSectors; i++ )
	{
		char		sectorFilename[64];
		sprintf(sectorFilename,"data/terrain/%c_%i.x", &filename, i+1 );

		//do stuff
	}
}
however this isnot quite working, the char* isnt being converted into the string in the filename. eg output is "data/terrain/$_1.x" Can anyone help? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Use this instead:

sprintf(sectorFilename,"data/terrain/%s_%i.x", filename, i+1 );

%s -> String.
& -> You don't need it since filename is already a char*.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!