C for Rust Programmers
a day ago
- C's boolean type was not built-in until C99 and used macros for true/false; C23 made it a primitive.
- C strings are null-terminated, requiring explicit allocation of extra byte and careful handling of length vs pointers.
- Integer widths in C are platform-dependent; using fixed-width types from <stdint.h> is recommended for portability.
- Error handling in C relies on magic integers and errno, with no compiler enforcement, leading to potential segfaults.
- C uses separate field access operators (`.` for values, `->` for pointers) unlike Rust's unified `.`.
- Arrays decay to pointers when passed to functions, causing sizeof to return pointer size instead of array size.
- C has no references or borrow checking, only raw pointers, enabling pointer arithmetic but risking memory errors.