file i/o - alternatives to constant filenames?
I have visual c++ .net 2003 and I'm wondering
how I can write programs to read from and write to
files that can be selected at runtime. It seems
to me that traditional c++ file i/o is insufficient
because it requires a constant string for the filename.
I don't really want to do MFC applications -
I'd like to do directx applications if possible, but
would also wonder how to do this in console c++.
Any help would really be appreciated.
Or, more correctly:
std::string filename;
std::cin >> filename;
std::ofstream out_file(filename.c_str());
std::string filename;
std::cin >> filename;
std::ofstream out_file(filename.c_str());
Functions that take a const char * do not require their arguments to be string literal constants. Rather the const char * signifies that the character array passed to the function will not be modified by the called function. You can pass a non-const character array to the function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement