How do you create file with a variable in C++? -
I was wondering how to put a variable where is "example.txt"
below :
offstream file; File.open ("example.txt");
Just put a variable there: - P
if you Use the std :: string
and you need to get the .c_str ()
by using the const char *
so that your options are The types are:
const char * filename = "example.txt" file.open (filename);
or:
std :: string filename = "example.txt" file.open (filename.c_str ());
Comments
Post a Comment