16,472
社区成员
发帖
与我相关
我的任务
分享
CStdioFile file("c:\\time.txt",CFile::modeReadWrite);
CString timeStr;
CTime start;
BOOL b = FALSE;
while (file.ReadString(timeStr))
{
int nYear, nMonth, nDay, nHour, nMin, nSec;
sscanf(timeStr.GetBuffer(255),"%d-%d-%d %d:%d:%d",&nYear,&nMonth,&nDay,&nHour,&nMin,&nSec);
CTime t(nYear, nMonth, nDay, nHour, nMin, nSec);
if (!b)
{
start = t;
b = !b;
}
CTimeSpan ts = t - start;
CString s = ts.Format( "Total days: %D, hours: %H, mins: %M, secs: %S" );
MessageBox(s);
}
file.Close();