# **[](https://en.cppreference.com/w/c/header/stdio)** provides buffered file and console I/O: `printf`, `scanf`, `fopen`, `fclose`, and stream operations. Use `snprintf` instead of `sprintf` to avoid buffer overflows; always check return values. Compile with `-lm` if using math functions; I/O functions link with the C library automatically. ## Example This example opens a file, writes formatted data, seeks, and reads it back. ```c // compile: gcc -o studioexample studioexample.c // run: ./studioexample // description: write to file, seek to start, read back line by line #include int main() { FILE* f = fopen("/tmp/stdio.txt", "w+"); if (!f) { perror("fopen"); return 1; } fprintf(f, "line 1\n"); fprintf(f, "line 2\n"); fprintf(f, "line 3\n"); rewind(f); char buf[64]; while (fgets(buf, sizeof(buf), f)) printf("read: %s", buf); fclose(f); return 0; } ```