A few Lessons ago, I mentioned that a variable such as **months couldn’t be used to declare an array. That’s true because the **months construction doesn’t use array notation. Duh. That doesn’t mean that **months is totally out of luck.
Continue reading
A Simple Calculator
Of course computers can do math! Of course, programming has some math in it! Yet one reason that programmers are not necessarily geniuses at math is that it’s the computer that does the math, not the programmer. To prove that truth, why not code your very own calculator program?
Continue reading
Direct String Manipulation
As programmer, you have a choice: You can manipulate information as it’s sent to output or you can manipulate it in memory and then send the result to output. Depending on what the program does, however, you may not have that luxury. Sometimes you must make modifications in memory, saving them for later.
Continue reading
The Art of String Manipulation: Spaces to Newlines
The C language lacks a sack of tools for manipulating strings. For most string-mangling operations, you’re pretty much left to carve out your own tools. Doing so may involve pointers, but it doesn’t necessarily have to.
Continue reading
Getting Shifty
Something that you can do in the C language that C++ programmers cannot is employ the shift operators. These operators, << and >>, serve as I/O operators in C++. In C, however, they can be used to manipulate values at the bit level in C, which is part of the C language’s mid-level heritage.
Continue reading
Splitting Things in Half
It’s pretty safe to avoid your first instinct when it comes to dividing two integers. That first instinct is most likely to typecast the int values as float. That works, and many times it can be the best solution, but it’s not always the solution.
Continue reading
The Multi-Dimensional Array Grid
Data is is just data. Organize that data and it becomes information. When it comes to organizing data in the C language, the first tool you probably learned was the array.
Continue reading
Of Course, ****d is a Variable
The unary * operator is used both to declare a pointer and access the value at that pointer’s location. When the value is the address of another pointer, two * unary operators are used. When the value is the address of an address of an address of an address, then four * unary operators are used. I kid you not.
Continue reading
How the ** Pointer Variable Works Best
The pointer-to-a-pointer variable does have a purpose, but fortunately it’s a very specific and rare purpose. And, no, that purpose isn’t to make you wish you had learned to program in Java.
Continue reading
The Ongoing Mystery of the ** Variable
The ** notation can really make a beginning C programmer blanch. In fact, a lot of Java programmers probably fled from the C language just after the initial lesson on pointers. They’d turn to stone even to glance at a variable like **blorf. You don’t need to cower under a desk with those people.
Continue reading