Hi
I have this function, I built 2 days ago, yesrterday it was working perfectly, today not.
I use this function to bring the file of this month, like where are in month 2, so it suppose to bring me the file of month2 daily_report_02.txt , yesterday it brought it to me but today it suppose to bring the same file as we are still in month 2, but it brought me daily_report_03.txt, WWWWWWWWWHyyyyyCode:char *month(int months, const char *format, char *text, size_t size) { time_t t; if ( time ( &t ) != (time_t)(-1) ) { struct tm *local = localtime ( &t ); if ( local ) { local->tm_mon += months; t = mktime ( local ); if ( t != (time_t)(-1) ) { local = localtime ( &t ); if ( local ) { if ( strftime ( text, size, format, local ) ) { return text; } } } } } return 0; }
notice please
one final this because I read a input file of the previous day, so the out put should be put in the same month, what I mean is if today is 1 feb so my code will read the input file of the 31/1/2006 and will put its out put in Jan (Summary_Report_01.txt).
I use this function and call it in main
please fix my errorCode:( notes field contain the path) string outpath= field + month(-1, "Daily_Report_%d.txt", outfile, sizeof outfile) ; ofstream outfile(outpath.c_str(), ios::out | ios::app);



LinkBack URL
About LinkBacks


