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 […]


Debugging – An Easy Way to Catch Typing Errors in C++

A common bug in C++ programming is mixing different data types together – generally, this is inadvertent. I developed this technique back in 1997 or 1998 after my recommendation that all types be made classes was shot down. It requires your programming style does not use the fundamental C++ data types directly, but instead you […]


Programming Error – Incorrect Array Declaration

In C++, we can declare an array by using the new operator: char *p = new char[50]; // dynamically allocate an array of 50 char This is useful in functions when we don’t know in advance how large the array should be or if we want to allocate the array in the heap instead of […]