Format Specifiers in C++

Format Specifiers in C++:


Format Specifiers in C++

Visual Studio 2010
2 out of 2 rated this helpful - Rate this topic

This topic applies to:
EditionVisual BasicC#F#C++Web Developer
Express
Topic does not applyTopic does not applyTopic does not applyTopic appliesTopic does not apply
Pro, Premium, and Ultimate
Topic does not applyTopic does not applyTopic does not apply
Topic applies
Topic applies
When debugging native code in the Watch window or QuickWatch dialog box, you change the format in which a value is displayed using format specifiers.
(Most format specifiers are for native code only, but Visual C# has a limited set of format specifiers. For information, see Format Specifiers in C#.)
You can also use format specifiers in the Immediate window, Command window, and even in source windows. If you hover the cursor over an expression in those windows, the result will appear in a DataTip. DataTips will reflect the format specifier in the DataTip display.
Suppose nVar is an integer variable, and the Watch window shows that it contains the value 0x0065. To see value expressed as a character instead of an integer, in the Name column, after the variable name, add the character format specifier, c:
nVar,c
Instead of the integer value 0x0065, the Value column now displays the character value, 101 'e'.
If you want to apply a format specifier to elements of an array or members of an object, you must apply it directly to each element or member. You cannot apply it to the array or object as a whole. For example, suppose you had an array nArray and wanted to see the first four elements in character format. You would enter these expressions in the Watch window:
nArray[0],c
nArray[1],c
nArray[2],c
nArray[3],c
The following tables show the format specifiers recognized by the debugger.
SpecifierFormatExpressionValue Displayed
d,i
signed decimal integer
0xF000F065, d
-268373915
u
unsigned decimal integer
0x0065, u
101
o
unsigned octal integer
0xF065, o
0170145
x,X
Hexadecimal integer
61541, x
0x0000f065
l,h
long or short prefix for: d, i, u, o, x, X
00406042,hx
0x0c22
f
signed floating point
(3./2.), f
1.500000
e
signed scientific notation
(3./2.), e
1.500000e+000
g
signed floating point or signed scientific notation, whichever is shorter
(3./2.), g
1.5
c
Single character
0x0065, c
101 'e'
s
String
0x0012fde8, s
"Hello world"
su
Unicode string
0x0012fde8, su
"Hello world"
s8
UTF-8 string
0x0012fde8, s8
"Hello world"
hr
HRESULT or Win32 error code. (The debugger now decodes HRESULTs automatically, so this specifier is not required in those cases.
0x00000000L, hr
S_OK
wc
Window class flag.
0x00000040, wc
WC_DEFAULTCHAR
wm
Windows message numbers
0x0010, wm
WM_CLOSE
!
raw format, ignoring any data type views customizations
i !
4
The following table contains formatting symbols used for memory locations. You can use a memory location specifier with any value or expression that evaluates to a location.
SymbolFormatExpressionValue Displayed
ma
64 ASCII characters
ptr, ma
0x0012ffac .4...0...".0W&.......1W&.0.:W..1...."..1.JO&.1.2.."..1...0y....1
m
16 bytes in hexadecimal, followed by 16 ASCII characters
ptr, m
0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A            30 57 26 00 00       .4...0...".0W&..
mb
16 bytes in hexadecimal, followed by 16 ASCII characters
ptr, mb
0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A            30 57 26 00 00       .4...0...".0W&..
mw
8 words
ptr, mw
0x0012ffac 34B3 00CB             3084 8094       22FF 308A             2657 0000      
md
4 doublewords
ptr, md
0x0012ffac 00CB34B3 80943084 308A22FF 00002657
mq
2 quadwords
ptr, mq
0x0012ffac 7ffdf00000000000 5f441a790012fdd4
mu
2-byte characters (Unicode)
ptr, mu
0x0012fc60 8478 77f4 ffff ffff 0000 0000 0000 0000
If you have a pointer to an object you want to view as an array, you can use an integer to specify the number of array elements:
ptr,10

댓글

이 블로그의 인기 게시물

4,5,6 띠 저항의 색띠를 읽는 법(띠저항 값)

수지에서 인천공항 리무진 버스 (인천공항버스정보)(2022년3월업데이트)

수지에서 김포공항 리무진 버스 ( 2022년 3월 업데이트 )