Hello....I have a quick question:
How do you open a file for input, using a var.
eg. I store "test.map" in the var MapFile.
then I use:
ifstream File1;
File1.open (MapFile);
Why doesn't this work?
Hello....I have a quick question:
How do you open a file for input, using a var.
eg. I store "test.map" in the var MapFile.
then I use:
ifstream File1;
File1.open (MapFile);
Why doesn't this work?
Is test.map in your local directory? What variable type is MapFile ?
zen
Yes the test.map is in the same dir as the project file, and the MapFile is a string...
When I use
ifstream File1;
File1.open ("test.map");
instead of
ifstream File1;
File1.open (MapFile);
it works fine...
Also the file is opened in a seperate function:
from the main() i call
LoadMap("test.map");
wich uses the function:
void LoadMap(string MapFile)
{
ifstream File1;
File1.open (MapFile);
...
}
It is a string, as defined in cstring.h?
With this data type, iut will NOT automatically convert to a const char * which is what you need. To get that, you'd need to use
File1.open(MapFile.c_str());