Tag: C

Constant Pointers in C: Reading Right to Left

The “const” keyword in the C programming language, when applied to pointers, can be quite confusing to read. How do you read a variable declaration like “const char *const *const p”? This blog post explains how to read these declarations, and demonstrates the technique of reading them from right to left.

Aborting on Programming Errors

Programming errors can be as small and subtle as an off-by-one error in a loop, or as large as a flaw in the implementation or design of an important algorithm. What should our code do when it runs into this type of error? In most cases, we shouldn’t be afraid just to make our program abort.

Wrapping Multiline Macros in C With Do/While

This blog post describes logical errors that can occur with multiline macros in C programming, and demonstrates how to resolve them directly in the definition of the macro itself. After reading this post, you should understand why wrapping multiline C macros with a “do/while” statement is a best practice to avoid these logical errors.