File + stringstream

Hey, I am trying to open a file using a concatenation of string and numbers. I have method called loadmap(int level).

This is part of code where problem lies:
1
2
3
4
5
6
7
std::stringstream ss;
	ss<<"..//Data//Maps//map_"<<level<<"//map_"<<level<<".txt";
	std::string temp = ss.str();
	const char* cstr = temp.c_str();
	FileHandle = fopen(cstr,"r");
	if(FileHandle==NULL)
		return -1;


But it does not work, is there a reason? Is there a better way to do what I am trying?
Add cout<<temp; and post what you get.
Why are you using "//" instead of '/' or '\\' ?
Sorry, I got it sorted, My level name was map_0....but I was passing in 1 to the function. Lol.

@ L B Why not? ;D
Last edited on
Because "//" doesn't work for me?
It's probably SDL specific then ^^
Topic archived. No new replies allowed.