-
File names
Hi,
I'm trying to dynamically specify a filename to be equal to something the user specifies at an earlier point in the system. The code I have is...
Code:
ofstream out;
out.open(file, ios::out|ios::app);
...where file is a string variable. However I get an error saying it cannot convert std::string to const char *. Is there any way to use a C++ string to specify a file name or if that isn't possible how can I convert it to a C string?
Cheers
-
Code:
out.open(file.c_str(), ios::out|ios::app);
-
that's working now, Cheers!