afxDump,TRACE,TRACE0

调试的三个工具:TRACE,afxDump,MessageBox。

1、afxDump<<"/n 变量i 的值为:"<<i;

VC中的dump是一个对象内容的标准方法,它的输出流是流向调试窗口,所以必须保证程序是调试版。

程序也可以建造调试模式:

#ifdef _DEBUG

afxDump<<"/n 变量i 的值为:"<<i;

#endif

 

2、TRACE is limited to sending a total of 512 characters at a time. If you call TRACE with formatting commands, the total string length after the formatting commands have been expanded cannot be more than 512 characters, including the terminating NULL. Exceeding this limit causes an ASSERT.

// example for TRACE

 

TRACE0 is similar to TRACE, and is one variant of a group of trace macros that you can use for debug output. The group includes:

TRACE0 - Takes a format string (Only) and can be used for simple text messages which are dumped to afxDump


TRACE1 - Takes a format string plus one argument (one variable which is dumped to afxDump)


TRACE2 - Takes a format string plus two arguments (two variables which are dumped to afxDump)


TRACE3 - Takes a format string plus three arguments (three variables which are dumped to afxDump)
TRACE0 does nothing if you have compiled a release version of your application. As with TRACE, it only

dumps data to afxDump if you have compiled a debug version of your application.

 

 

给下面代码每一行给上注释并说明这段代码的意思#include "pch.h" #include "FinBudgetSupport.h" #include <map> time_t StringToDateTime(char* str) { tm tm_; int year, month, day, hour, min, sec; afxDump << str << "\n\n\n\n"; sscanf_s(str, "%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec); tm_.tm_year = year - 1900; tm_.tm_mon = month - 1; tm_.tm_mday = day; tm_.tm_hour = hour; tm_.tm_min = min; tm_.tm_sec = sec; tm_.tm_isdst = -1; time_t t_ = mktime(&tm_); return t_; } CString DateTimeToString(time_t _time) { tm *_tm = new tm(); gmtime_s(_tm ,&_time); CString t_str; t_str.Format(_T("%d-%d-%d %d:%d:%d"), _tm->tm_year+1900, 1+_tm->tm_mon, _tm->tm_mday, _tm->tm_hour , _tm->tm_min, _tm->tm_sec); delete _tm; return t_str; } CString _toCString(double _value) { CString t_str; t_str.Format(_T("%lf"), _value); return t_str; } CString _toCString(int _value) { CString t_str; t_str.Format(_T("%d"), _value); return t_str; } double _toDouble(CString _str) { return _ttof(_str); } char* CStringToCharArray(CString str) { int str_len = WideCharToMultiByte(CP_ACP, 0, str, str.GetLength(), NULL, 0, NULL, NULL);//计算字节数 char* CharArray = new char[str_len + 1]; WideCharToMultiByte(CP_ACP, 0, str, str.GetLength(), CharArray, str_len, NULL, NULL); CharArray[str_len] = '\0'; return CharArray; } void SplitString(const std::string& s, std::vector<std::string>& v, const std::string& c) { std::string::size_type pos1, pos2; pos2 = s.find(c); pos1 = 0; while (std::string::npos != pos2) { v.push_back(s.substr(pos1, pos2 - pos1)); pos1 = pos2 + c.size(); pos2 = s.find(c, pos1); } if (pos1 != s.length()) v.push_back(s.substr(pos1)); }
最新发布
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值