void recordTime()
{
const char pa[256] = "//home//projects//testService//recordTime";
ofstream fout;
fout.open(pa, ios::app);
time_t currTime;
struct tm *tp;
char buf[256];
while(1)
{
currTime = time(NULL);
tp = localtime(&currTime);
strftime(buf, 256, "%B %e, %Y, %H:%M:%S", tp);
fout<<"current time is "<<buf<<endl;
sleep(1);
}
fout.close();
} |