Is that because there is an extra 0 in the filename? The two pieces of code generate two different filenames, so if one works and one doesn't it's probably because the one that works is creating the correct filename.
Is that because there is an extra 0 in the filename? The two pieces of code generate two different filenames, so if one works and one doesn't it's probably because the one that works is creating the correct filename.
. . . you could always use something like
to see the exact filename that is being generated.Code:filename = "C:\\Dragonways\\Map\\" + mapfile + ".txt"; cout << filename << endl; ifstream readMap(filename.c_str());
The problem is likely that you have to be exact when you specify a filename, down to the last character. If the file is called "(mapfile variable)0.txt" then your code that doesn't work , well, it won't work.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.