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
Category Archives: Lesson
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
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
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
The size_t Variable Type
The C language has its basic variable types: char, int, float, double, struct, and that oddball newbie _Bool. Anything else you see as a “variable” is probably a convenient shortcut manufactured by using a typedef statement. Some of these typedef variables are faily standard, including the most common one, size_t.
Continue reading
Safe Coding Practices – putchar() as a Loop Condition
It’s not unsafe to use putchar() as condition inside a while loop. If you dare try it, however, you must ensure that it checks for file errors. That’s an area where my own code often falls short.
Continue reading
Safe Coding Practices – getchar() and putchar()
I confess that I get sloppy with getchar() and putchar(). These are macros, not functions, but the issue is that their return value is an int, not a char variable. The reason why is important if you want to follow safe coding practices.
Continue reading
Safe Coding Practices – Terminating a String
String constants and strings created or manipulated by C library functions all set that terminating null character, '\0'. When you build your own strings, however, it’s easy to completely forget that null character. I know. I’ve done it.
Continue reading