Plenty of C coders implemented boolean variables long before the C99 standard introduced the _Bool type. Programmers defined TRUE and FALSE constants, they used char or short variables as toggles, or they manipulated bits in a byte to simulate binary and boolean operations. With all that going on, you’d think adding a boolean variable type to C and calling it bool would have been a no-brainer. It wasn’t.
Continue reading
Ruminations on the _Bool variable type
One of the C language keywords added in the C99 update is _Bool. It’s an underscore keyword, which means it lacks the respect gained by the other keywords — even the useless ones like auto.
Continue reading
Oscillation – Solution
For my solution to this month’s Oscillation Exercise I created a toggle variable. This variable switches between 1 and -1. It sets the direction for the cascading values.
Continue reading
Is continue Necessary?
On this blog, I try to show examples for all the C language keywords, but continue is one I struggle with. It doesn’t appear in Beginning Programming with C For Dummies. It barely appears in my C All-in-one Desktop Reference For Dummies. Even the venerable K&R manual has difficulty explaining how this keyword is worthy.
Continue reading
Oscillation
Going back and forth happens frequently in the real world, and not just when you forget to pick up something at the store. Pendulums swing back and forth. The tide rises and falls. Politicians waffle.
Continue reading
The Perils of typedef
The typedef keyword is both handy and dangerous. It’s handy because it allows the pantheon of C variable types to be expressed in different ways. It’s dangerous for the same reason.
Continue reading
Playing with a Double-Linked List
In last week’s Lesson, I demonstrated code that builds a double-linked list: Each structure in the list references both the next structure and the previous structure. The first and last structure addresses are saved. And NULL pointers within the list its start and end. How all that junk becomes useful is apparent as you work with the list.
Continue reading
Building a Double-Linked List
Similar to a linked list, a double-linked list requires that you work on both the current item in the list as well as the the previous item. You just have one additional structure member to update, which is the pointer from the current item to the previous structure.
Continue reading
Swapping Strings – Solution
This month’s Exercise involves swapping elements between two string arrays. A number of solutions exist (as always), but because the “strings” are really pointers, the solution can be very specific. Yes, you just might have to use that dratted ** notation. Brace yourselves.
Continue reading
The Dreaded Double-Linked List
As if a linked list itself isn’t one of the most terrifying things in C, another beast exists: the double-linked list. It mixes structures and pointers and offers gross potential for extreme mayhem. That sounds like fun!
Continue reading