standard

C Standard Library

C standard library patterns

C
framework
Default

Details

Language / Topic
cC
Category
framework
Compatible Frameworks
standard

Rules

balanced
- Prefer portable C standard library APIs. Use explicit abstraction boundaries for platform-specific code.
- Use `<stdint.h>` types (`uint32_t`, `int64_t`) instead of `int`/`long` for fixed-width integers.
- Use `<string.h>` bounded functions (`strncpy`, `snprintf`) over unbounded ones (`strcpy`, `sprintf`) to prevent buffer overflows.
- Prefer `<stdlib.h>` `exit()` codes: `EXIT_SUCCESS` (0) and `EXIT_FAILURE` (1) — never use magic numbers for process exit.
- Use `<string.h>` safely: prefer `strncpy`, `snprintf` over unbounded `strcpy`, `sprintf`.
- Use `<errno.h>` for error reporting from library functions. Check and reset `errno` appropriately.
- Use `<stdlib.h>` for memory management. Always check `malloc`/`realloc` return values.
- Prefer `<stdbool.h>` (`bool`, `true`, `false`) over integer flags for boolean logic.