how do i save time to a file?

Posted by blood on Stack Overflow See other posts from Stack Overflow or by blood
Published on 2010-05-05T04:07:43Z Indexed on 2010/05/05 4:18 UTC
Read the original article Hit count: 295

Filed under:
|

hi, i have a program that saves data to file and i want to put a time stamp of the current date/time on that log but when i try to write the time to the file it will not show up.

#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>
#include <sstream>
#include <direct.h>
#include <stdio.h>
#include <time.h>

using namespace std;

string header_str = ("NULL");


int main()
{

for(;;)
{


        stringstream header(stringstream::in | stringstream::out);   

        header << "datasdasdasd_";

         time_t rawtime;

         time ( &rawtime );

        header << ctime (&rawtime);
        header_str = header.str();

        fstream filestr;

        filestr.open ("C:\\test.txt", fstream::in | fstream::out |   fstream::app | ios_base::binary | ios_base::out);

        for(;;)
        {
            filestr << (header_str);

        }

        filestr.close();


}

return 0;
}

anyone know how to fix this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about time