On this page
printf
Prev: stdio.h | Up: stdio.h | Next: fprintf
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — printf
Tags: #public #prog #c #stdlib #stdio #tier/core
Include
#include <stdio.h>
Signature & Overview
int printf(const char *restrict fmt, ...);
Writes formatted output to stdout; returns number of characters written or negative on error.
Notes & Pitfalls
- Match specifiers to exact types:
%zuforsize_t,PRId64forint64_t,%pwith(void*)for pointers—mismatches are UB (-Wformatcatches them).
Example
#include <stdio.h>
int main(void) {
printf("name=%s count=%zu\n", "widgets", (size_t)42);
}
Linked from
Related notes
- tuts/c/stdlib/stdio/fprintf Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/feof shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ferror shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fflush shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fgets shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fputs shared tags: #c, #prog, #stdio, #stdlib, #tier