As a programmer, you encounter new counting bases: binary, hexadecimal, and perhaps octal. As a human, you use decimal, but decimal is only a recent invention. Before 1600 or so, if you worked with numbers you probably used Roman numerals.
Continue reading
Category Archives: Lesson
The Ghost of Octal
Programmers become exposed to multiple counting bases as well as ways of representing values. As a human, you work in base 10, probably thanks to your 10 fingers. When you program, you learn about base 2 binary and base 16 hexadecimal. You study exponential notation as well, especially for crunching very large or very small values.
Somewhere in the mire, you encounter base 8, octal. You nod appropriately at the information as it’s glossed over, then you move on and never return to discover what was once a huge deal.
Continue reading
Yes! It’s a String – or Number!
The standard library functions atoi() and atof() work well to translate text (ASCII) input into values, an int or float, respectively. When your code must know whether a string is really a value, more processing is required.
Continue reading
Value or String?
My philosophy is to treat the input as a string until I can confirm that it’s not. The question then rises as to how strings can best translate into a value.
Continue reading
Manipulate Pointers in Functions, Part V
In Part II of this series, I showed code that let you pass a pointer’s address to a function. Within that function, the address can be manipulated and value at that address displayed. Can the same thing be done with a two-dimensional array, which is loosely related to a ** pointer?
Continue reading
Manipulate Pointers in Functions, Part IV
Those programmers I wrote about in last week’s Lesson, the ones who avoid the ** pointer notation, usually do so by using a two-dimensional array instead of the ** pointer thing. It’s a quick substitute, but it’s not exactly the same thing.
Continue reading
Manipulate Pointers in Functions, Part III
I know C programmers who make it their goal to avoid pointers — even where necessary. It’s possible to do so, and many have cheat sheets to help them. Then comes the ** pointer monster, which can be avoided altogether . . . until you need to manipulate a pointer variable’s own address within a function. Then you’re cursed.
Continue reading
Manipulate Pointers in Functions, Part II
When a function must manipulate a pointer’s address, the argument passed is a pointer-pointer, not a pointer. Confused? Oh, I’m just getting started . . .
Continue reading
Manipulate Pointers in Functions, Part I
It’s common to pass a pointer to a function. Within the function, you can manipulate the data the pointer references without having to return that data from the function. This aspect of a pointer is what makes C a powerful — and scary — programming language. But what about when you need to manipulate the pointer’s address in the function?
Continue reading
Comparing Three Items
Logic can be frustrating, especially for non-Vulcans. The computer is kind of a Vulcan, so logic comes naturally to the machine. Programming languages are packed with logical expressions. A programmer’s duty is to convert human thoughts into the raw, powerful logic the computer understands — and end up with the desired result.
Continue reading