Skip to content
C stdio.h
Functions
File Operation Functions
- remove()
- Deletes a file from the filesystem, permanently removing it if successful.
- rename()
- Renames a file or moves it to a new location by specifying a new filename or path.
- tmpfile()
- Creates and opens a temporary file in binary mode, which is automatically deleted when closed.
- tmpnam()
- Generates a unique temporary filename that can be used for creating temporary files.
File Access Functions
- fclose()
- Closes an open file, flushing any unwritten data and releasing the file handle.
- fflush()
- Flushes the output buffer of a stream, ensuring that any buffered data is written to the file or terminal.
- fopen()
- Opens a file with a specified mode (e.g., read, write, append) and returns a file pointer for further operations.
- freopen()
- Reopens an existing file stream with a new file or mode, useful for redirecting standard streams.
- setbuf()
- Sets the buffer for a file stream, either enabling or disabling buffering.
- setvbuf()
- Controls the buffering mode of a stream, allowing customization of buffer size and type.
Formatted Input/Output Functions
- fprintf()
- Writes formatted output to a file stream, similar to
printf()
but directing output to a file.
- fscanf()
- Reads formatted input from a file stream and stores the values in specified memory locations.
- printf()
- Prints formatted output to the standard output (stdout), typically the console.
- scanf()
- Reads formatted input from the standard input (stdin) and stores the values in specified memory locations.
- snprintf()
- Writes formatted data to a character array, ensuring the output does not exceed the buffer size (safe alternative to
sprintf()
).
- sprintf()
- Writes formatted output to a string without checking for buffer overflow.
- sscanf()
- Reads formatted input from a string and stores the values in specified memory locations.
- vfprintf()
- Writes formatted output to a file stream using a variable argument list, similar to
fprintf()
but accepting arguments via va_list
.
- vfscanf()
- Reads formatted input from a file stream into a variable argument list, similar to
fscanf()
but using va_list
.
- vprintf()
- Prints formatted output to the standard output (stdout) using a variable argument list, similar to
printf()
but using va_list
.
- vscanf()
- Reads formatted input from the standard input (stdin) into a variable argument list, similar to
scanf()
but using va_list
.
- vsnprintf()
- Writes formatted data to a character array using a variable argument list, ensuring the output does not exceed the buffer size (safe alternative to
vsprintf()
).
- vsprintf()
- Writes formatted output to a string using a variable argument list, similar to
sprintf()
but using va_list
.
- vsscanf()
- Reads formatted input from a string into a variable argument list, similar to
sscanf()
but using va_list
.
Character Input/Output Functions
- fgetc()
- Reads a single character from a file stream and advances the file position indicator.
- fgets()
- Reads a string from a file stream into a character array, stopping at a newline or reaching the specified limit.
- fputc()
- Writes a single character to a file stream and advances the file position indicator.
- fputs()
- Writes a null-terminated string to a file stream.
- getc()
- Reads a single character from a file stream, equivalent to
fgetc()
.
- getchar()
- Reads a single character from standard input (stdin) and returns its ASCII value.
- gets()
- Reads a string from standard input (stdin) into a character array. **Deprecated** due to potential buffer overflow risks.
- putc()
- Writes a single character to a file stream, equivalent to
fputc()
.
- putchar()
- Writes a single character to standard output (stdout).
- puts()
- Writes a string to standard output (stdout), automatically appending a newline character.
- ungetc()
- Pushes a character back onto a file stream, making it available for subsequent reads.
Direct Input/Output Functions
- fread()
- Reads a block of data from a file stream into a buffer, typically used for reading binary files.
- fwrite()
- Writes a block of data from a buffer to a file stream, commonly used for writing binary files.
File Positioning Functions
- fgetpos()
- Retrieves the current position of the file position indicator in a file stream and stores it in a
fpos_t
object.
- fseek()
- Moves the file position indicator to a specific location within a file stream, allowing random access.
- fsetpos()
- Sets the file position indicator to a previously saved position using an
fpos_t
object.
- ftell()
- Returns the current position of the file position indicator in a file stream.
- rewind()
- Resets the file position indicator to the beginning of a file stream.
Error Handling Functions
- clearerr()
- Clears the error and end-of-file indicators for a given file stream.
- feof()
- Checks whether the end-of-file (EOF) indicator is set for a given file stream, returning a nonzero value if EOF has been reached.
- ferror()
- Checks whether an error has occurred in a given file stream, returning a nonzero value if an error is detected.
- perror()
- Prints an error message to the standard error output (stderr) describing the last error that occurred.