This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Printf" – news · newspapers · books · scholar · JSTOR(February 2015) (Learn how and when to remove this message)
"Format string" and "Format specifiers" redirect here. For format strings used by the scanf family of functions, see scanf.
printf is a C standard library function that formats text and writes it to standard output.
The name, printf is short for print formatted where print refers to output to a printer although the functions are not limited to printer output.
The standard library provides many other similar functions that form a family of printf-like functions. These functions accept a format string parameter and a variable number of value parameters that the function serializes per the format string and writes to an output stream or a string buffer.
The format string is encoded as a template language consisting of verbatim text and format specifiers that each specify how to serialize a value. As the format string is processed left-to-right, a subsequent value is used for each format specifier found. A format specifier starts with a % character and has one or more following characters that specify how to serialize a value.
The format string syntax and semantics is the same for all of the functions in the printf-like family.
Mismatch between the format specifiers and count and type of values can cause a crash or vulnerability.
The printf format string is complementary to the scanf format string, which provides formatted input (lexing a.k.a. parsing). Both format strings provide relatively simple functionality compared to other template engines, lexers and parsers.
The formatting design has been copied in other programming languages.
printf is a C standard library function that formats text and writes it to standard output. The name, printf is short for print formatted where print refers...
kernel log. It provides a printf-like abstraction and its parsing of the format string and arguments behave similarly to printf. It acts as a debugging...
k){if(k<1||k>2){printf("out of range\n"); printf("this function requires a value of 1 or 2\n");}else{ printf("Switching\n");switch(k){case 1:printf("1\n");break;case...
(repeat--) { printf("process(%d)\n", i ); printf("process(%d)\n", i + 1); printf("process(%d)\n", i + 2); printf("process(%d)\n", i + 3); printf("process(%d)\n"...
string parameter in certain C functions that perform formatting, such as printf(). A malicious user may use the %s and %x format tokens, among others, to...
into the source code. The latter is sometimes called printf debugging, due to the use of the printf function in C. This kind of debugging was turned on...
functionality of the types defined in the <stdint.h> header. It defines macros for printf format string and scanf format string specifiers corresponding to the types...
strlen( s ); } int main( int argc, char *argv[] ) { const char *a = NULL; printf( "size of a = %lu\n", foo_len(a) ); exit( 0 ); } Using the GCC compiler...
Example # ALGOL 68 example # main:( REAL number; getf(stand in,($g$,number)); printf(($"Number is: "g(6,4)"OR "$,number)); # OR # putf(stand out,($" Number is:...
68. Input format strings are complementary to output format strings (see printf), which provide formatted output (templating). Mike Lesk's portable input/output...
as printf), but also allowing a function called with printf-like syntax to process non-trivial objects. template<typename... Params> void my_printf(const...