For an argument, functions in the C language can take literal values, equations, the result from another function, or any combination of these items. It’s a feature that’s both flexible and confusing.
Continue reading
From Text to Integer
A program prompts for a value. The user types “12345” at the keyboard, but that input is a string and not the value 12,345. Therefore, the code must convert the string into a value. This task can be accomplished in a number of ways.
Continue reading
How a for Loop Works
I received an interesting question the other day. A student asked me to explain a for loop. Dutifully, I set out and gave my description, which he found entirely baffling. So I backed up again and gave this explanation:
Continue reading
ASCII Programming Tricks, Round II
You probably don’t even think about it. How do the toupper() and tolower() functions do their magic? Both functions take a letter of one case and convert it to the same letter of the opposite case. They don’t touch any other characters or symbols.
Well, how would you code it?
Continue reading
ASCII Programming Tricks, Round I
The clever organization of ASCII character codes lends itself to some useful programming tricks. One of those tricks involves converting from character codes ‘0’ through ‘9’ to integer values zero through nine.
Continue reading
ASCII Character Codes
ASCII refers to character codes from zero through 127. These codes are interpreted identically on all modern computers. They represent basic alphabetic, numeric, and symbol characters.
Continue reading
The Inverse Pyramid – Solution
The task for this month’s Exercise was to create code that outputs an inverse number pyramid.
Here’s what such a thing looks like:
0000000000
999999999
88888888
7777777
666666
55555
4444
333
22
1
Name Your Variables
As you sit and madly pound out code, variable names are probably not at the top of your list of things to do better. I tend to use x for my loops, c or ch for characters, and other variables, including a, b, and c. This is an acceptable approach, but for larger programs such variable names not doing you any favors.
Continue reading
The Inverse Pyramid
Two things that seem to be difficult for a beginning C programmer are numbers and their formatted presentation. I admit: These things are difficult to understand. Therefore some practice is in order.
Continue reading
A Few Pointers on Structure Pointers
Structures aren’t really scary. Pointers are scary. Obviously, a good way to make structures more terrifying it so throw some pointers at them.
Continue reading