FAQ
Why does my long variable behave differently on Windows versus Linux?
Windows 64-bit uses the LLP64 data model, where long stays 32 bits, while 64-bit Linux and macOS use LP64, where long is 64 bits. Code that assumes long always matches pointer size or always holds 64-bit values will misbehave on Windows.
What is the actual range of an unsigned 32-bit integer?
0 to 4,294,967,295. This is a fixed value regardless of platform since it depends only on the bit width, which is why uint32_t is defined the same everywhere even though plain unsigned int's size is technically platform-dependent.
Should I use int or int32_t in new code?
Use int32_t (or another stdint.h fixed-width type) whenever the exact size matters, such as file formats, network protocols, or hardware registers. Plain int is fine for ordinary loop counters and small values where the exact width is irrelevant.
Why does printf use %f for both float and double?
C's variadic functions automatically promote float arguments to double, so by the time printf reads the argument it is always a double regardless of the variable's declared type, and %f handles that correctly. scanf does not promote its pointer arguments, which is why it needs %f for a float* and %lf for a double*.
What is the difference between size_t and ptrdiff_t?
size_t is unsigned and represents object sizes or array indices, which can never be negative. ptrdiff_t is signed and represents the difference between two pointers, which can be negative if one pointer is subtracted from an earlier one.