The printf() function is most concerned with getting the number of conversion characters — the % placeholders — to match the number of variables specified. Beyond that, it’s rather ambivalent as to whether the types match properly.
Continue reading
Author Archives: dgookin
The C Variable Myth
A variable in C is a myth. Oh, yeah, it’s a location in memory. That’s pretty much it. After declaring the variable, the compiler — and you, the programmer — pretty much rely upon faith that the variable works and can actually be useful.
Continue reading
Min and Max
The C language is rather weak when it comes to array functions. In fact, as far as I know, the standard library doesn’t contain a single array function.
Continue reading
The Month Array
Why present the current date as 8/31/2013 when you can express it as August 31, 2013? Because some things are easy to program and some are easy for the program’s user to read.
Continue reading
Why Not Float All the Time?
What’s the point of using integers when you could simply code programs using floating-point values all the time to always get the best results? The reason is a good one, but it takes some explaining.
Continue reading
Unique Random Numbers
The goal is to write code that generates random numbers, but never the same value twice. After all, if you’re coding a card game or generating lotto picks, it’s unrealistic to expect the same value appear multiple times.
Continue reading
Pick a Card, Any Card
Last week’s Lesson discussed how to monitor random numbers by using an array: When a random value is drawn, it’s corresponding array element is incremented. By continuing that same thought, you can easily ensure that the same random number isn’t used when programming a card game. But first, the game itself!
Continue reading
Never the Same Number Twice
One of the most common questions I get from my For Dummies programming titles is regarding the lotto programs. That code demonstrates how you can randomly draw lotto balls without drawing the same ball twice.
Continue reading
The Caesarian Cipher
A Caesarian Cipher is one of the simplest, weakest forms of encryption. Supposedly developed by Julius Caesar, it’s a letter substitution cipher: A becomes C, B becomes D, C becomes E, and so on.
Continue reading
The Difference Between NULL and Zero
University professors will try to drive the point into your head all semester: NULL and zero are not the same thing! But yet, you’ve looked into memory, you’ve examined the code. That thing they call NULL sure does look like a zero! What’s the big difference?
Continue reading