You should be able to just use string concatenation with +
.
mfile.open ( accname + ".txt");
If you are not on c++ 11
, then you probably need a C-style string.
mfile.open ( (accname + ".txt").c_str());
5
solved C++ Probllem with output [closed]