On this page
stdio.h
Prev: stdlib | Up: stdlib | Next: stdlib.h
Rel: stdio.h & File I/O Guide, c/builtins
Ref: cppreference — <stdio.h>
Tags: #public #prog #c #stdlib #stdio #index
Include
#include <stdio.h>
Overview
Buffered stream input/output, formatted printing, and file management (FILE *).
Core (#tier/core)
- printf — Writes formatted output to
stdout; returns number of characters written or negative on error. - fprintf — Writes formatted output to a specific
FILE *stream (such asstderror an open file). - snprintf — Bounds-checked formatted write into
buf(at mostsize - 1chars plus NUL terminator). - fgets — Reads at most
count - 1characters up to and including'\n'intobuf, always NUL-terminating. - fopen — Opens a file stream (
"r","w","a","rb","wb","wx"); returnsNULLon failure and setserrno. - fclose — Flushes buffered writes and closes
stream; returns0on success orEOFon error. - fread — Reads up to
countobjects ofsizebytes fromstream; returns the number of full objects read. - fwrite — Writes
countobjects ofsizebytes tostream; returns the number of objects written. - perror — Prints
s, a colon, and the human-readable error message for currenterrnotostderr.
Standard (#tier/standard)
- vsnprintf — Variadic
va_listversion ofsnprintffor building custom logging or formatting helpers. - fputs — Writes a NUL-terminated string to
streamwithout appending a newline (unlikeputs). - fseek — Moves the file position indicator relative to
SEEK_SET,SEEK_CUR, orSEEK_END. - ftell — Returns the current byte offset in
stream(or-1Lon error). - fflush — Flushes buffered output data to the OS;
fflush(NULL)flushes all open output streams. - feof — Returns non-zero if the end-of-file indicator has been set by a previous failed read.
- ferror — Returns non-zero if the error indicator is set on
stream. - remove — Deletes the file (or empty directory) at
path; returns0on success. - rename — Renames or moves a file atomically within the same filesystem; returns
0on success.
Specialized (#tier/specialized)
- setvbuf — Sets stream buffering mode (
_IOFBFfull,_IOLBFline,_IONBFunbuffered) before any I/O occurs. - tmpfile — Creates and opens a unique binary temporary file (
"wb+") that is automatically deleted on close or normal exit.
Legacy / Avoid (#tier/legacy)
- sprintf — Unbounded formatted string write with no buffer-size check. Prefer snprintf().
- gets — Reads a line from
stdinwith zero bounds checking; removed from ISO C11. Prefer fgets(). - scanf — Reads formatted input from
stdin; prone to unbounded%sreads, integer overflow UB, and leftover newline issues. Prefer fgets().
Linked from
- tuts/c/stdlib
- tuts/c/stdlib/stdio/fclose
- tuts/c/stdlib/stdio/feof
- tuts/c/stdlib/stdio/ferror
- tuts/c/stdlib/stdio/fflush
- tuts/c/stdlib/stdio/fgets
- tuts/c/stdlib/stdio/fopen
- tuts/c/stdlib/stdio/fprintf
- tuts/c/stdlib/stdio/fputs
- tuts/c/stdlib/stdio/fread
- tuts/c/stdlib/stdio/fseek
- tuts/c/stdlib/stdio/ftell
- tuts/c/stdlib/stdio/fwrite
- tuts/c/stdlib/stdio/gets
- tuts/c/stdlib/stdio/perror
- tuts/c/stdlib/stdio/printf
- tuts/c/stdlib/stdio/remove
- tuts/c/stdlib/stdio/rename
- tuts/c/stdlib/stdio/scanf
- tuts/c/stdlib/stdio/setvbuf
- tuts/c/stdlib/stdio/snprintf
- tuts/c/stdlib/stdio/sprintf
- tuts/c/stdlib/stdio/tmpfile
- tuts/c/stdlib/stdio/vsnprintf
- tuts/c/stdlib/stdlib
Related notes
- tuts/c/stdlib Linked here; links to this page; shared tags: #c, #index, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/feof Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/ferror Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fflush Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fgets Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fopen Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fprintf Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fputs Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio/fread Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib