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!
===Parameter field=== The parameter field is optional. If included, then matching specifiers to values is {{em|not}} sequential. The numeric value {{samp|n}} selects the n-th value parameter. This is a [[POSIX]] extension; not [[C99]].{{needs citation|date=April 2025}} {{Table alignment}} {| class="wikitable col1center" |- ! Text ! Description |- | {{tt|''n''$}} | ''n'' is the index of the value parameter to [[serialization|serialize]] using this format specifier |} This field allows for using the same value multiple times in a format string instead of having to pass the value multiple times. If a specifier includes this field, then subsequent specifiers must also. For example, <syntaxhighlight lang="c"> printf("%2$d %2$#x; %1$d %1$#x",16,17); </syntaxhighlight> outputs: {{samp|17 0x11; 16 0x10}} This field is particularly useful for [[Localization (computing)|localizing]] messages to different [[natural language]]s that use different [[word order]]s. In [[Microsoft Windows API|Windows API]], support for this feature is via a different function, {{code|printf_p}}.
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)