Thread: what happened to the function today

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    32

    what happened to the function today

    Hi
    I have this function, I built 2 days ago, yesrterday it was working perfectly, today not.

    Code:
    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;
    }
    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, WWWWWWWWWHyyyyy


    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
    Code:
    ( 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);
    please fix my error
    Last edited by yes; 02-03-2006 at 05:02 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM