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

请教Ushort类型的输出格式是什么?给位师兄师姐帮帮忙啊

2012-12-14 
请问Ushort类型的输出格式是什么?给位师兄师姐帮帮忙啊!我想Trace一个Ushort类型的数据,请问一下怎么写代

请问Ushort类型的输出格式是什么?给位师兄师姐帮帮忙啊!
我想Trace一个Ushort类型的数据,请问一下怎么写代码 ?
[解决办法]
unsigned short value;
printf("%d",value);
就是个16位的无符号整数
[解决办法]
"%hu"
Size and Distance Specification
The optional prefixes to type, h, l, and L, specify the “size” of argument (long or short, single-byte character or wide character, depending upon the type specifier that they modify). These type-specifier prefixes are used with type characters in printf functions or wprintf functions to specify interpretation of arguments, as shown in the following table. These prefixes are Microsoft extensions and are not ANSI-compatible.

Table R.6   Size Prefixes for printf and wprintf Format-Type Specifiers

To Specify Use Prefix With Type Specifier 
long int l d, i, o, x, or X 
long unsigned int l u 
short int h d, i, o, x, or X 
short unsigned int h u 
__int64 I64 d, i, o, u, x, or X 
Single-byte character with printf functions  h c or C 
Single-byte character with wprintf functions h c or C 
Wide character with printf functions l c or C 
Wide character with wprintf functions l c or C 
Single-byte – character string with printf functions h s or S 
Single-byte – character string with wprintf functions h s or S 
Wide-character string with printf functions l s or S 
Wide-character string with wprintf functions l s or S 


Thus to print single-byte or wide-characters with printf functions and wprintf functions, use format specifiers as follows.

To Print Character As Use Function With Format Specifier 
single byte printf c, hc, or hC 
single byte wprintf C, hc, or hC 
wide wprintf c, lc, or lC 
wide printf C, lc, or lC 


To print strings with printf functions and wprintf functions, use the prefixes h and l analogously with format type-specifiers s and S.

[解决办法]
USHORT
 Unsigned SHORT. The range is 0 through 65535 decimal.

This type is declared in WinDef.h as follows:


typedef unsigned short USHORT;
 

热点排行