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
Author Archives: dgookin
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
Balancing Accounts
Difficulty: Medium
Your bank receives two deposits or credits and three bills or debits. The credits cover the debits, meaning that your balance should never go below zero, but the bank has clever software: The bills are calculated first, which thrusts your account into negative territory complete with fees — even though the deposits cover the bills. Is this obnoxious behavior the result of greedy bankers or clever programming?
Continue reading
Options for the strfmon() Function
The strfmon() function, introduced in last week’s Lesson properly formats a monetary value for specific regions. To unlock the function’s various features, you must understand and use formatting placeholders.
Continue reading
Exploring the strfmon() Function
The C programming language doesn’t sport the thousands of functions (or methods or what-have-you) available in Java. They say Java programmers may never use or even know the variety. With many fewer functions available in the standard C library, I would think to know them all. Then along comes another one I’ve neither used nor heard of. This week’s Lesson covers such as function, strfmon().
Continue reading