I hope you enjoyed crafting your solution for this month’s Exercise. It’s just for fun, as I assume no one is going to mess with C to such a degree that their code becomes so completely unrecognizable. Still, C coders are a mischievous bunch.
Continue reading
The _Generic Keyword
The C11 standard added the “underscore” bunch to the C language’s traditional keywords:
_Alignas
_Alingof
_Atomic
_Bool
_Complex
_Generic
_Imaginary
_Noreturn
_Static_assert
_Thread_local
I don’t routinely use any of these in my programs, beyond trying a few out to see how they work. The _Bool keyword comes in handy. The rest? Well, they’re worth exploring from a curiosity standpoint. For this week’s Lesson, I reveal the mysteries of the _Generic keyword.
Continue reading
Unravel the Mystery Code
Difficulty: Easy
The C compiler preprocessor is a sneaky and powerful thing. I’m unsure of any other programming languages that have such a tool.
Continue reading
Putting the memset() Function to Work
My approach for initializing a buffer is to use a loop and assign each byte a value such as zero or the null character, '\0'. It’s tedious, but necessary. And for the impatient, some functions are available to perform this task for you.
Continue reading
How Big is Your BUFSIZ?
When my code requires a random odd buffer, I generally assign it a given size in some holy computer value: 16, 32, 64, and so on. But a defined constant exists, BUFSIZ, that can also be used to set a buffer size safely and consistently on all C compilers.
Continue reading
Zero and NULL and Pointers and Stuff
The defined constant NULL represents a null or empty pointer. I’ve written before that the constant isn’t defined as zero, though such an assumption could lead you into trouble.
Continue reading
Eight Years of the C For Dummies Blog
Today marks 8 years that this blog has been online. The first post was made April 13, 2013. The blog was up for a few months before the book C Programming For Dummies was released. This way material would be available for the first readers.
Continue reading
Positive or Negative Zero
Mathematicians truly enjoy doing their math thing. As a mortal human, I don’t have a spot for math things on my “fun” spectrum. Yet, one of the more jolly things the math nerds do is discuss the value zero.
Continue reading
Balancing Accounts – Solution
I hope you had a wee bit of a struggle with your solution to this month’s Exercise. It involves a lot of decisions and proper steps in the right order to hold off on debits so that the bank account never dips below zero.
Continue reading
Sign Bits
I recall the math class where negative numbers were introduced. I was appalled. From Star Trek, I easily accepted the concept of antimatter, but the notion of negative values deeply offended me.
Continue reading