Preprocessor – The #define Directive

This is the most complicated of the preprocessor directives (a little over 7 pages is devoted to it in the C99 spec and the C++98 spec devotes about 4 pages to it). Behaviour of the #define directive is the same in both C and C++. C99 added variable argument macros; the upcoming C++0x standard adds […]


Why You Don't Need to Defragment Your Hard Drive

Defragmenting your hard drive is often presented as a way of speeding up your computer – mostly, it is a good way to quickly wear out your hard drive, waste a lot of time and risk data loss. In general, you do not need to defragment your hard drive. Even if files are fragmented, it […]


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


C as a Strongly Typed Language

Contrary to popular belief, C is a strongly typed language; the problem is that C programming practice favours using weak typing. What is a Type? A type is something that has a set of values associated with it, a set of operations that can be performed on it, and a representation (how it looks at […]


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


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


Preprocessor – The Token Pasting (##) Operator

This is probably the least understood and most poorly documented preprocessor operator. The token pasting (##) operator simply eliminates any white space around it and concatenates (joins together) the non-whitespace characters together. It can only be used in a macro definition. It is used to create new tokens. It may not be the first or […]


Why Writing is Hard

“There’s nothing to writing. All you do is sit down at a typewriter and open a vein.” ~Walter Wellesley “Red” Smith “Writing is easy: All you do is sit staring at a blank sheet of paper until drops of blood form on your forehead.” ~Gene Fowler Pretty much anyone who has ever sat down to […]


Proving the Pythagorean Theorem

We learned the Pythagorean Theorem in grade school: The square of the length of the hypotenuse is equal to the sum of the squares of the other two sides. Often written as A2 + B2= C2. The Pythagorean Theorem is much more than just a mathematical curiosity, it is a basic and useful mathematical property […]


Understanding the Distance Equation (Formula)

If you want to find the distance between two points, the length of a line, or the magnitude of a vector then you use the distance formula, which usually looks something like this: This is just the Pythagorean Theorem, slightly rearranged. The solution to this problem shows how (with a few steps) it is possible […]


How to Install WordPress into a Folder Other than \wordpress under XAMPP

These instructions are for WordPress version 3.1, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.2.0, and 3.2.1 into a folder other than \wordpress under XAMPP 1.7.3 running on Windows XP with Service Pack 3 installed. You may want to install into a different folder for various reasons, the two most common being: (1) you want to have multiple […]


An Easy Way to Fragment Your Hard Drive

Following on yesterdays blog post on A Faster Way To Defragment Your Hard Drive, I decided to blog on an easy way to fragment your hard drive – although, this is usually not what we intend to do. After a while, our hard drives tend to fill up with (mostly junk), and we get a […]