What Are System Calls?
System calls are the interface between your program and the operating system kernel. While
stdio.h functions like printf and fopen are buffered wrappers, system calls interact directly with the kernel.Low-Level File I/O
c
stdio vs System Calls
| Feature | stdio (fopen) | System calls (open) |
|---|---|---|
| Returns | FILE* | int (file descriptor) |
| Buffering | Yes (automatic) | No (raw) |
| Portability | C standard | POSIX |
| Performance | Higher-level | Lower-level, less overhead |
Writing with System Calls
c
Standard File Descriptors
| fd | Name | C equivalent |
|---|---|---|
| 0 | STDIN_FILENO | stdin |
| 1 | STDOUT_FILENO | stdout |
| 2 | STDERR_FILENO | stderr |
c
Summary
System calls give you direct kernel access at the cost of portability and convenience. Use them when you need fine-grained control over I/O, or when building systems software.