Say you must read 2048 bytes from a file. Which of the following fread() statements works for you: A, B, both, or neither?
A. c = fread( buffer, 2048, 1, fh);
B. c = fread( buffer, 1, 2048, fh);
Continue reading
Say you must read 2048 bytes from a file. Which of the following fread() statements works for you: A, B, both, or neither?
A. c = fread( buffer, 2048, 1, fh);
B. c = fread( buffer, 1, 2048, fh);
Continue reading
Like doing anything for a long period of time, I find myself often using the same approach to solving a programming puzzle. It’s habit. It’s tradition. And it often hinders my insight into the language.
Continue reading
The fall-through effect of the switch-case structure can be extremely useful, as demonstrated in last week’s Lesson. For slicing words from a string, you can easily match multiple word separators, saving you from coding complex statements or weirdo if-else structures. But a problem arises when multiple word separators appear.
Continue reading
C language keywords often used in a switch-case structure are switch, case, default, and break. Only switch and case are required. You can omit the default condition. And the break keyword is used to avoid execution falling through the structure, yet sometimes that may be a useful effect.
Continue reading
The switch-case structure is the most complex decision tool in the C language. Yes, the ternary operator is more cryptic, but a proper switch-case structure involves more keywords: switch, case, default, and break. The break keyword is what I feel makes the structure most interesting.
Continue reading
In last week’s Lesson, I waxed on about how a text message can be concealed in a delightful manner, making it not look like a text message at all. To get to that point, you must write some code that translates plain text into the values desired.
Continue reading
Typing in sample code was all the rage back when I first learned assembly language. The programs were short. Most of them I could understand based on my limited knowledge, but I still enjoyed seeing the result and wondering how they did it. Hopefully, I’d learn something.
Continue reading
If I were well-versed in a handful of programming languages, I’m sure I’d find one better than C for examining line lengths in a text file. Perhaps Perl could do the trick? or even the shell language? Regardless, I know C.
Continue reading
I admit that sometimes I need to see someone else’s code before a formerly obscure function becomes useful to me. A case in point is the strchr() function, which I rarely use.
Continue reading
In last week’s Lesson, I demonstrated how macros can save time, effectively replacing one-line functions in your code. One place I’ve used macros in my own code is when performing binary math operations.
Continue reading