I was wondering how to put a variable where "example.txt"
is below:
ofstream file;
file.open ("example.txt");
just put a variable there :-P
if you use std::string
then you need to get the const char*
using .c_str()
so your options are:
const char *filename = "example.txt"
file.open(filename);
or:
std::string filename = "example.txt"
file.open(filename.c_str());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.