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!
===Family=== Variants of {{code|printf}} in the C standard library include: {{code|fprintf}} outputs to a [[File (computing)|file]] instead of standard output. {{code|sprintf}} writes to a [[string buffer]] instead of standard output. {{code|snprintf}} provides a level of safety over {{code|sprintf}} since the caller provides a length ''n'' that is the length of the output buffer in bytes (including space for the trailing nul). {{code|asprintf}} provides for safety by accepting a string [[Handle (computing)|handle]] (char**) argument. The function [[memory allocation|allocates]] a buffer of sufficient size to contain the formatted text and outputs the buffer via the handle. For each function of the family, including printf, there is also a variant that accepts a single [[va list|{{code|va_list}}]] argument rather than a variable list of arguments. Typically, these variants start with "v". For example: {{code|vprintf}}, {{code|vfprintf}}, {{code|vsprintf}}. Generally, printf-like functions return the number of bytes output or -1 to indicate failure.<ref>{{cite web | last=Kerrisk| first=Michael |date=Feb 2, 2025 |title=sprintf(3) β Linux manual page |website=man7.org |url=https://man7.org/linux/man-pages/man3/sprintf.3.html |access-date=Mar 19, 2025}}</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)