C

Preprocessor – the #include Directive

Behaviour of the #include directive is the same in both C and C++. Purpose It is used to include / insert / copy paste the contents of the specified file into the current file. Format #include <file name> or #include "file name" or #include preprocessor tokens All preprocessor directives begin with the # symbol. It […]

Writing

Writing Quickly

In a previous post, I discussed how writing is hard because we get frustrated that the process of writing is so much slower than our process of ideation. However, we often make the process even harder by writing at a slower pace than we are capable. As a writer, it’s easy to become overwhelmed by […]

Blog

Jetpack Site Stats can be Misleading

I have the Jetpack plugin installed and use the Stats module in it to monitor activity on this site. It gives the following notice: Keep in mind we don’t count your own visits. Unfortunately, this is not completely true – if you are not logged in, it will count your visits to your site. To […]

Joomla

Adding Adsense to Your Joomla! 1.6 Site

This tutorial shows you how to display Google Adsense ads on your Joomla! 1.6.x website without installing an extension. Requires you have a Google Adsense account. Should work for other ad providers that provide you with a code snippet for ads on your site. Joomla! 1.6 is now obsolete and Joomla.org no longer provides support […]

C

Preprocessor – the #undef Directive

Behaviour of the #undef directive is the same in both C and C++. Purpose It is used to undefine a macro. A macro is an identifier (or label) followed by replacement text. There is only a single namespace for macros. A program which redefines an existing macro is considered to be malformed – even though […]

C

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

Blog

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

C++

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

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

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

C++

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

C

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