BASIC4MCU | C언어 | C언어 | printf Substitution Types
페이지 정보
작성자 master 작성일2018-02-05 23:42 조회2,175회 댓글0건본문
Type field[edit]
The Type field can be any of:
Character Description %
Prints a literal %
character (this type doesn't accept any flags, width, precision, length fields).d
,i
int
as a signed decimal number.%d
and%i
are synonymous for output, but are different when used withscanf()
for input (where using%i
will interpret a number as hexadecimal if it's preceded by0x
, and octal if it's preceded by0
.)u
Print decimal unsigned int
.f
,F
double
in normal (fixed-point) notation.f
andF
only differs in how the strings for an infinite number or NaN are printed (inf
,infinity
andnan
forf
,INF
,INFINITY
andNAN
forF
).e
,E
double
value in standard form ([-
]d.ddde
[+
/-
]ddd). AnE
conversion uses the letterE
(rather thane
) to introduce the exponent. The exponent always contains at least two digits; if the value is zero, the exponent is00
. In Windows, the exponent contains three digits by default, e.g.1.5e002
, but this can be altered by Microsoft-specific_set_output_format
function.g
,G
double
in either normal or exponential notation, whichever is more appropriate for its magnitude.g
uses lower-case letters,G
uses upper-case letters. This type differs slightly from fixed-point notation in that insignificant zeroes to the right of the decimal point are not included. Also, the decimal point is not included on whole numbers.x
,X
unsigned int
as a hexadecimal number.x
uses lower-case letters andX
uses upper-case.o
unsigned int
in octal.s
null-terminated string. c
char
(character).p
void *
(pointer to void) in an implementation-defined format.a
,A
double
in hexadecimal notation, starting with0x
or0X
.a
uses lower-case letters,A
uses upper-case letters.[3][4] (C++11 iostreams have ahexfloat
that works the same).n
Print nothing, but writes the number of characters successfully written so far into an integer pointer parameter.
Java: indicates a platform neutral newline/carriage return.[5]
Note: This can be utilized in Uncontrolled format string exploits.
https://en.wikipedia.org/wiki/Printf_format_string
댓글 0
조회수 2,175등록된 댓글이 없습니다.