1. 记录时间
#include <atlstr.h>
#include <time.h>
clock_t clockBegin, clockEnd; clockBegin = clock(); // do sth. clockEnd = clock(); double totaltime = (double)(clockEnd-clockBegin)/CLOCKS_PER_SEC; //输出时间是s CString csTemp; csTemp.Format("%f", totaltime); OutputDebugString(csTemp);
2. 报错
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format (...)
解决
csTemp.Format(_T("%f"), totaltime);