我有一个程序,将数据保存到文件,我想要在当前日期/时间的日志,但当我试图写入文件的时间它不会显示,但我写其他数据将。我如何节省时间到一个文件?
#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;
}
人知道如何解决这一问题?
为什么你有一个无限循环? – 2010-05-05 04:09:58
无限居然平方:-) – paxdiablo 2010-05-05 04:12:13
无限乐趣=的xD – blood 2010-05-05 04:47:46