Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Printf
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Type field=== The type field can be any of: {{Table alignment}} {| class="wikitable col1center" |- ! Text ! Description |- | {{tt|%}} |Output a literal {{tt|%}} character; does not accept flags, width, precision or length fields |- | {{tt|d}}, {{tt|i}} |(signed) {{tt|int}} formatted as decimal; {{tt|%d}} and {{tt|%i}} are synonymous except when used with <code>scanf</code> |- | {{tt|u}} | {{tt|unsigned int}} formatted as decimal. |- | {{tt|f}}, {{tt|F}} |{{tt|double}} formatted as [[Fixed-point arithmetic|fixed-point]]; {{tt|f}} and {{tt|F}} only differs in how the strings for an infinite number or [[NaN]] are printed ({{tt|inf}}, {{tt|infinity}} and {{tt|nan}} for {{tt|f}}; {{tt|INF}}, {{tt|INFINITY}} and {{tt|NAN}} for {{tt|F}}) |- | {{tt|e}}, {{tt|E}} |{{tt|double}} formatted as in exponential notation {{tt|''d''.''ddd''eΒ±''dd''}}; {{tt|E}} results in {{tt|E}} rather than {{tt|e}} to introduce the exponent; the exponent always contains at least two digits; if the value is zero, the exponent is {{tt|00}}; in Windows, the exponent contains three digits by default, e.g. {{tt|1.5e002}}, but this can be altered by Microsoft-specific {{code|_set_output_format}} function |- | {{tt|g}}, {{tt|G}} |{{tt|double}} formatted as either fixed-point or exponential notation, whichever is more appropriate for its magnitude; {{tt|g}} uses lower-case letters, {{tt|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, and that the precision field specifies the total number of significant digits rather than the digits after the decimal; the decimal point is not included on whole numbers |- | {{tt|x}}, {{tt|X}} |{{tt|unsigned int}} formatted as [[hexadecimal]]; {{tt|x}} uses lower-case letters and {{tt|X}} uses upper-case |- | {{tt|o}} |{{tt|unsigned int}} formatted as [[octal]] |- | {{tt|s}} |null-terminated string |- | {{tt|c}} |{{tt|char}} |- | {{tt|p}} |[[Pointer (computer science)|Pointer]] formatted in an implementation-defined way |- | {{tt|a}}, {{tt|A}} |{{tt|double}} in hexadecimal notation, starting with {{tt|0x}} or {{tt|0X}}. {{tt|a}} uses lower-case letters, {{tt|A}} uses upper-case letters<ref>{{cite web| url= https://www.gnu.org/software/libc/manual/html_node/Table-of-Output-Conversions.html | work= The GNU C Library Reference Manual | at= sec. 12.12.3 | title= Table of Output Conversions | author= Free Software Foundation | author-link= Free Software Foundation | publisher= self-published | access-date=2014-03-17 }}</ref><ref> [http://www.cplusplus.com/reference/cstdio/printf/ "printf"] ({{tt|%a}} added in C99) </ref> |- | {{tt|n}} | Outputs nothing but writes the number of characters written so far into an integer [[Pointer (computer science)|pointer]] parameter; in [[Java (programming language)|Java]] this prints a [[newline]]<ref>{{cite web|url=https://docs.oracle.com/javase/tutorial/java/data/numberformat.html|title=Formatting Numeric Print Output |website=The Java Tutorials | publisher=Oracle Inc.|access-date=19 March 2018}}</ref> |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)