-
Conditional Assignments
Sometimes, you’ll have a scenario with two variables, and you need to use one of them based on a simple test. Rather than a long and awkward if / else statement, C allows the use of the ? : form. It is perfectly acceptable to write: int i,j,k,l; … i = (j > 5? k […]
-
Preprocessor #s, ##s, and other weird stuff
In the post on strings for enums , I used two types of pound symbols in the preprocessor macros: # and ##. Here’s some more detail:
-
i++ Incremements and Execution Sequence
Quiz: What will the following code print? int i = 5; printf(“%d “, i++ * i++); printf(“%d\n”, i);
-
Multiple Pointer Declarations
Quick quiz: What does the following code do: char* p1, p2 ?
-
Posting Code in WordPress (and comments!)
As you may have noticed, I often post code (including (X)HTML) in these posts. A classic problem is how to display a line like <html_tag> without having the web browser treat it as a tag and trying to process it. [UPDATE: Fix for comments!]