CString TimeToString()
{
CTime nowTime = CTime::GetCurrentTime();
int iYear = nowTime.GetYear();
int iMonth = nowTime.GetMonth();
int iDay = nowTime.GetDay();
int iHour = nowTime.GetHour();
int iMinute = nowTime.GetMinute();
int iSecond = nowTime.GetSecond();
char strTemp[20];
char strTemp_1[20];
char strTime[100];
itoa(iYear, strTemp, 10);
strcpy(strTime, " ");
strcat(strTime, strTemp);
strcat(strTime, "/");
if (iMonth < 10)
{
strcpy(strTemp, "0");
itoa(iMonth, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iMonth, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, "/");
if (iDay < 10)
{
strcpy(strTemp, "0");
itoa(iDay, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iDay, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, "--");
if (iHour < 10)
{
strcpy(strTemp, "0");
itoa(iHour, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iHour, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, ":");
if (iMinute < 10)
{
strcpy(strTemp, "0");
itoa(iMinute, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iMinute, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, ":");
if (iSecond < 10)
{
strcpy(strTemp, "0");
itoa(iSecond, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iSecond, strTemp, 10);
}
strcat(strTime, strTemp);
CString sReturn;
sReturn.Format("%s", strTime);
return sReturn;}类似这样冗长的代码在程序中还有很多。。唉,因为每一段代码都有可能引发崩溃,所以又不能跳过不看。
{
CTime nowTime = CTime::GetCurrentTime();
int iYear = nowTime.GetYear();
int iMonth = nowTime.GetMonth();
int iDay = nowTime.GetDay();
int iHour = nowTime.GetHour();
int iMinute = nowTime.GetMinute();
int iSecond = nowTime.GetSecond();
char strTemp[20];
char strTemp_1[20];
char strTime[100];
itoa(iYear, strTemp, 10);
strcpy(strTime, " ");
strcat(strTime, strTemp);
strcat(strTime, "/");
if (iMonth < 10)
{
strcpy(strTemp, "0");
itoa(iMonth, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iMonth, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, "/");
if (iDay < 10)
{
strcpy(strTemp, "0");
itoa(iDay, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iDay, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, "--");
if (iHour < 10)
{
strcpy(strTemp, "0");
itoa(iHour, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iHour, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, ":");
if (iMinute < 10)
{
strcpy(strTemp, "0");
itoa(iMinute, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iMinute, strTemp, 10);
}
strcat(strTime, strTemp);
strcat(strTime, ":");
if (iSecond < 10)
{
strcpy(strTemp, "0");
itoa(iSecond, strTemp_1, 10);
strcat(strTemp, strTemp_1);
}
else
{
itoa(iSecond, strTemp, 10);
}
strcat(strTime, strTemp);
CString sReturn;
sReturn.Format("%s", strTime);
return sReturn;}类似这样冗长的代码在程序中还有很多。。唉,因为每一段代码都有可能引发崩溃,所以又不能跳过不看。
中间的- :可以用你想要的替换掉。为什么采用这么麻烦的手段?
这是个视频监控的程序,有远程端和本地端,我被告知崩溃是发生在网络报警频繁出现的时候。
楼上几位仁兄说得很好,调试、设断点,我也很同意,但是我这里并不具备运行环境(触发网络报警)。
所以只能看代码。。>_<
如果程序崩溃时有提示内存地址
也可以修改编译选项,生成map文件,根据崩溃地址定位
我尝试按住右边的滚动条来浏览它,但是拉到一半发现整个代码区都变成了白色,咦~难道这个家伙加了那么多空白行??我再把水平滚动条往右拉原来由于层层缩进,代码已经超出整个屏幕了。。我的VC6字体是CourierNew 9号,屏幕分辨率1280x1024。
周思博怎么说的来着?任何想要量化管理脑力工作者的工作量的行为都将是徒劳的.
假如一个公司用代码数以及修改问题数来衡量程序员的工作的话,那么结果将是程序员
先写出一大堆烂代码,然后再慢慢修改其中的bug
上面的代码我已经用AStyle格式化过了。