首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这个CString 的 Format输出为什么会不对

2012-03-29 
求助:这个CString 的 Format输出为什么会不对?unsigned__int64nData33CStringcsTemp_T( )CStringcs

求助:这个CString 的 Format输出为什么会不对?
unsigned   __int64   nData   =   33;
CString   csTemp   =   _T( " ");
CString   csFormat   =   _T( "0X%04X[%d] ");
csTemp.Format(csFormat,   nData,   nData);
得到结果:csTemp   ==   "0X21[0] ";
long   nData   =   33;
CString   csTemp   =   _T( " ");
CString   csFormat   =   _T( "0X%04X[%d] ");
csTemp.Format(csFormat,   nData,   nData);
得到结果:csTemp   ==   "0X21[33] ";
那位大虾知道原因?



[解决办法]
才15分钟就等不急?
输出格式是正确的.就是这个结果,要不对就是你格式写的不对
[解决办法]
msdn中
Format Specification Fields: printf and wprintf Functions
这个部分有说道

A format specification, which consists of optional and required fields, has the following form:

%[flags] [width] [.precision] [{h | l | ll | I | I32 | I64}]type

[解决办法]
贴出你的测试数据
[解决办法]
nData = 33;
csTemp = "0X21[33] ";

nData = 12345678901;
csTemp = "0X2DFDC1C35[12345678901] ";
[解决办法]
unsigned __int64 nData = 12345678901;
CString csTemp = _T( " ");
CString csFormat = _T( "0X%016I64X[%016I64d] ");
csTemp.Format(csFormat, nData, nData);
csTemp = "0X00000002DFDC1C35[0000012345678901] "
[解决办法]
结果跟我的一样啊,不明白你说那点不对.

热点排行