Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning
titleWarning

This section is under construction.

Wiki Markup
The formatted IO functions {{fprintf()}}, {{printf()}}, {{sprintf()}}, {{snprintf()}}, {{vfprintf()}}, {{vprintf()}}, {{vsprintf()}}, and {{vsnprintf()}} convert, format, and print their arguments under control of a _format_ string. According to \[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999|Programming Languages---C]\]

...

The following table summarizes C99-compliant conversion specifiers along with the flag characters (the apostrophe ('), -, { +}, the space character, and # in columns 2, through 5) and length modifiers (h, hh, l, ll, j, z, t, and L in columns 6 through 13) valid for each specification, and the type of the expected argument. Valid and meaningful combinations of a conversion specification, flag character, and length modifier is denoted by the (tick) symbol in the corresponding cell or by the name of the type argument effected by the length modifier. Valid combinations that have no effect are denoted by N/E. Using a combination of a conversion specification, flag character, and length modifier denoted by the (error) symbol or a specification not listed in the table, or an argument of an unexpected type may result in undefined behavior. See undefined behavior 145, 149, 150, 153, and 154 in Annex J of C99.

Conversion
Specifier
Character

' XSI

-
{ + }
SPACE


#


0

 


h


hh


l


ll


j


z


t


L

Argument
Type

d, i

(tick)

(tick)

(error)

(tick)

 

short

char

long

long long

intmax_t

size_t

ptrdiff_t

(error)

signed integer

o

(error)

(tick)

(tick)

(tick)

 

short

char

long

long long

intmax_t

size_t

ptrdiff_t

(error)

unsigned integer

u

(tick)

(tick)

(error)

(tick)

 

short

char

long

long long

intmax_t

size_t

ptrdiff_t

(error)

unsigned integer

x

(error)

(tick)

(tick)

(tick)

 

short

char

long

long long

intmax_t

size_t

ptrdiff_t

(error)

unsigned integer

X

(error)

(tick)

(tick)

(tick)

 

short

char

long

long long

intmax_t

size_t

ptrdiff_t

(error)

unsigned integer

f, F

(tick)

(tick)

(tick)

(tick)

 

(error)

(error)

N/E

N/E

(error)

(error)

(error)

long double

double or long double

e, E

(error)

(tick)

(tick)

(tick)

 

(error)

(error)

N/E

N/E

(error)

(error)

(error)

long double

double or long double

g, G

(tick)

(tick)

(tick)

(tick)

 

(error)

(error)

N/E

N/E

(error)

(error)

(error)

long double

double or long double

a, A

(tick)

(tick)

(tick)

(tick)

 

(error)

(error)

N/E

N/E

(error)

(error)

(error)

long double

double or long double

c

(error)

(tick)

(error)

(error)

 

(error)

(error)

wint_t

(error)

(error)

(error)

(error)

(error)

int or wint_t

s

(error)

(tick)

(error)

(error)

 

(error)

(error)

NTWS

(error)

(error)

(error)

(error)

(error)

NTBS or NTWS

p

(error)

(tick)

(error)

(error)

 

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

void*

n

(error)

(tick)

(error)

(error)

 

short*

char*

long*

long long*

intmax_t*

size_t*

ptrdiff_t*

(error)

pointer to integer

C XSI

(error)

(tick)

(error)

(error)

 

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

wint_t

S XSI

(error)

(tick)

(error)

(error)

 

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

NTWS

%

(error)

(tick)

(error)

(error)

 

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

none

Legend:

  • SPACE—the SPACE---the space (' ') character
  • _N/E_—No ---No Effect
  • NTBS—NTBS---char* argument pointing to a Null-Terminated Byte String
  • NTWS—NTWS---wchar_t* argument pointing to a Null-Terminated Wide character String
  • XSI—XSI---ISO/IEC 9945-2003 XSI extension

...

Section

LDRA tool suite

Include Page
c:LDRA_V
c:LDRA_V

 

 

Section

GCC

Include Page
c:GCC_V
c:GCC_V

 

Section

can detect violations of this recommendation when the -Wformat flag is used

Section

Klocwork

Include Page
c:Klocwork_V
c:Klocwork_V
Section

SV.FMT_STR.

 

...