2 ms·
I hung out in comp.std.c, read the C FAQ (https://c-faq.com/ https://c-faq.com/), and yes, read the actual language spec. For every C operation you type, ask y
by layer8 2y ago
I hung out in comp.std.c, read the C FAQ (https://c-faq.com/ https://c-faq.com/), and yes, read the actual language spec.
For every C operation you type, ask yourself what is its "contract", that is, what are the preconditions that the language or the library function expects the programmer to ensure in order for their behavior to be well-defined, and do you ensure them at the particular usage point? Also, what are the failure modes within the defined behavior (which result in values or states that may lead to precondition violations in subsequent operations)? This contractual thinking is key to correctness in programs in general, not just in C. The consequences of incorrect code are just less predictable in C.