C

Programming Error – Unintended String Concatenation

In an effort to be helpful, C and C++ compilers concatenate adjacent strings together. In the following example, the compiler will concatenate the two strings into a single string: printf("This is a string " "and this is another string."); Which is probably what you intended anyway. Because C and C++ are free form languages, adjacent […]

C

Keyword – switch, case, default

The switch keyword is probably the least well understood of the C/C++ language keywords (although, const probably comes a close second). The keywords switch, case, and default always go together and cannot be used independently in any other context. There is a small difference in behaviour between C and C++. Most programmers will never notice […]

C

Compilation Error – Improperly Defined Macro

Macros are tricky things to use in C/C++ programming. When they work, they work great. When they have bugs, they are a pain to troubleshoot. Macros are a simple text substitution done by the preprocessor. Whenever the macro name is encountered in your code, the preprocessor replaces it with the text to the right of […]