I would like to output an error report for my code with a filename formatted as "ErrorReport_date_time.rpt". as of right now i can output a file as "ErrorReport.rpt" or with no extension but when adding the date and time, it does not create a file.
void ErrorHandler::Open(char const filename[])
{
string fileType = ".rpt";
time_t t = time(0);
struct tm * now = localtime(&t);
stringstream ss;
ss << filename
<< (now->tm_year + 1900) << '-'
<< (now->tm_mon + 1) << '-'
<< (now->tm_mday) << '_'
<< (now->tm_hour) << ':'
<< (now->tm_min) << ':'
<< now->tm_sec
<< fileType
<< endl;
fileHandler->OpenFile(ss.str());
}
Supposing that my file handler opens, closes, and writes to a file successfully, where would I be going wrong?
You can't use :
or endl
in file names.