For itoa
, you are likely missing #include <stdlib.h>
. Note that itoa
is non-standard: the standard ways to format an integer as string as sprintf
and std::ostringstream
.
ofstream.open()
takes a const char*
, not std::string
. Use .c_str()
method to obtain the former from the latter.
Putting it together, you are looking for something like this:
ostringstream nameStream;
nameStream << "File - " << n << ".txt";
ofstream resultsFile(nameStream.str().c_str());