Printf format string

Printf format string

The printf format string is a control parameter used by a class of functions in the input/output libraries of C and many other programming languages. The string is written in a simple template language: characters are usually copied literally into the function's output, but format specifiers, which start with a % character, indicate the location and method to translate a piece of data (such as a number) to characters. Many languages other than C copy the printf format string syntax closely or exactly in their own I/O functions.

Comment
enThe printf format string is a control parameter used by a class of functions in the input/output libraries of C and many other programming languages. The string is written in a simple template language: characters are usually copied literally into the function's output, but format specifiers, which start with a % character, indicate the location and method to translate a piece of data (such as a number) to characters. Many languages other than C copy the printf format string syntax closely or exactly in their own I/O functions.
Depiction
Printf.svg
Has abstract
enThe printf format string is a control parameter used by a class of functions in the input/output libraries of C and many other programming languages. The string is written in a simple template language: characters are usually copied literally into the function's output, but format specifiers, which start with a % character, indicate the location and method to translate a piece of data (such as a number) to characters. "printf" is the name of one of the main C output functions, and stands for "print formatted". printf format strings are complementary to scanf format strings, which provide formatted input (lexing aka. parsing). In both cases these provide simple functionality and fixed format compared to more sophisticated and flexible template engines or lexers/parsers, but are sufficient for many purposes. Many languages other than C copy the printf format string syntax closely or exactly in their own I/O functions. Mismatches between the format specifiers and type of the data can cause crashes and other vulnerabilities. The format string itself is very often a string literal, which allows static analysis of the function call. However, it can also be the value of a variable, which allows for dynamic formatting but also a security vulnerability known as an uncontrolled format string exploit.
Is primary topic of
Printf format string
Label
enPrintf format string
Link from a Wikipage to an external page
www.and.org/vstr/%23cust-fmt
www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html
www.pixelbeat.org/programming/gcc/format_specs.html
java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html%23syntax
github.com/JuliaIO/Formatting.jl
en.cppreference.com/w/cpp/io/c/fprintf
technet.microsoft.com/en-us/library/ms175014.aspx
wiki.bash-hackers.org/commands/builtin/printf
Link from a Wikipage to another Wikipage
ALGOL 68
AMPL
Apache HTTP Server
Application programming interface
Awk
BCPL
Bourne again shell
C (programming language)
C++
C99
Category:Articles with example C code
Category:C standard library
Category:Unix software
Clojure
C standard library
D (programming language)
Elixir (programming language)
Escape character
Escape sequences in C
Exploit (computer science)
File:Printf.svg
Fixed-point arithmetic
Format (Common Lisp)
Format string attack
Fortran
F Sharp (programming language)
Function (computer science)
Function argument
Glibc
GNU Compiler Collection
GNU Linear Programming Kit
GNU Octave
Go (programming language)
GP
Haskell programming language
Hexadecimal
Integer
IOCCC
Iomanip
Iostream
IPv4
J (programming language)
Java (programming language)
JavaScript
Julia (programming language)
JVM
KornShell
LabVIEW
Lexical analysis
Linux kernel
Lua (programming language)
Maple (software)
MATLAB
Max (software)
Mini-language
ML (programming language)
Mythryl
Null-terminated string
Objective-C
Operator overloading
Parsing
Percent sign
Perl
PHP
POSIX
Printf (Unix)
Printf debugging
Programming languages
Python (programming language)
R (programming language)
Raku (programming language)
Red (programming language)
Ruby (programming language)
Scala (programming language)
Scanf format string
Static program analysis
String interpolation
String literal
Tcl
Template language
Transact-SQL
Turing-complete
Uncontrolled format string
Vala (programming language)
Version 4 Unix
Z shell
SameAs
4zchJ
m.02dscj
Mx4rvl5lY5wpEbGdrcN5Y29ycA
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf
Printf format string
Q838016
פורמט מחרוזת printf
格式化字符串
Subject
Category:Articles with example C code
Category:C standard library
Category:Unix software
Thumbnail
Printf.svg?width=300
WasDerivedFrom
Printf format string?oldid=1117752393&ns=0
WikiPageLength
24112
Wikipage page ID
473394
Wikipage revision ID
1117752393
WikiPageUsesTemplate
Template:Code
Template:CProLang
Template:Lowercase title
Template:Man
Template:More citations needed
Template:Pre
Template:Reflist
Template:Short description
Template:Tt
Template:Unix commands
Template:Use dmy dates