Skip to content
printf
EntityQ838016· pop 21· linked from 137 articles

350px|thumb|alt=Diagram illustrating syntax of printf function. The first argument to the function is a template string, which may contain format specifiers, which are introduced with the percent sign (%) character. Format specifiers instruct printf how to interpret and output values given in the corresponding arguments which follow the format string. printf replaces the format specifiers with the accordingly-interpreted contents of the remaining arguments, and outputs the result.|An example call to the printf function

Wikidata facts

Image
Printf.svg
Show 1 more fact
Sources (2)

via Wikidata · CC0

~21 min read

Article

28 sections
Contents
  • History
  • 1950s: Fortran
  • 1960s: BCPL and ALGOL 68
  • 1970s: C
  • 1990s: Shell command
  • 2000s: Java
  • 2000s: -Wformat safety
  • 2020s: std::print
  • Format specifier
  • Syntax
  • Parameter field
  • Flags field
  • Width field
  • Precision field
  • Length field
  • Type field
  • Custom data type formatting
  • Vulnerabilities
  • Format string attack
  • Uncontrolled format string exploit
  • Memory write
  • Related functions
  • Family
  • Other contexts
  • See also
  • Notes
  • References
  • External links

350px|thumb|alt=Diagram illustrating syntax of printf function. The first argument to the function is a template string, which may contain format specifiers, which are introduced with the percent sign (%) character. Format specifiers instruct printf how to interpret and output values given in the corresponding arguments which follow the format string. printf replaces the format specifiers with the accordingly-interpreted contents of the remaining arguments, and outputs the result.|An example call to the printf function

'''' is a C standard library function and is also a Linux terminal (shell) command that formats text and writes it to standard output. The function accepts a format C-string argument and a variable number of value arguments that the function serializes per the format string. Mismatch between the format specifiers and count and type of values results in undefined behavior and possibly program crash or other vulnerability.

Gallery (2)

Connections

Categories