To code a card game, you must start with the deck: 52 cards divided into 4 suits each consisting of 10 number cards and three face cards. Seems easy.
Continue reading
Category Archives: Lesson
Structures and Arrays, Part III
I’ve wrapped up most of the oddities about structure/pointer/array notation in the past two Lessons (Part I and Part II). All that’s left is for me to go insane and start allocating structures as pointers with all their members as pointers.
Continue reading
Structures and Arrays, Part II
When it comes to structures and pointers, the structure-pointer notation is used only when the structure itself is allocated as a pointer (block of memory), not when a structure member is a pointer. Let me review from last week’s Lesson:
Continue reading
Structures and Arrays, Part I
Structures in C have their own issues when it comes to structure-pointers and structures within pointers. I wrote about this issue a few months back.
Another structure issue occurs with arrays within structures and arrays of structures. It also involves interesting notation — especially when you add pointers to the mix.
Continue reading
Extremely Buffered Output
A few weeks back, I wrote a post on the fflush() function, which immediately relieves an output buffer, releasing its contents. The mirror opposite of this function might be another output control function, setbuf().
Continue reading
The Teeniest of Tiniest
It took me a while to figure out the significance of the nextafter() function. Though I understand what it does now, I still can’t figure out how it’s useful, though I assume it has a valid purpose otherwise it wouldn’t be in the standard library.
Continue reading
Take it to the Limit
It’s been a while since I’ve been seriously concerned about wasting system resources. Back when I programmed a TRS-80 Model III with only 48K of RAM, keeping an eye on memory usage was vital. Today, not so much. In fact, if you desire to write code that consumes a lot of memory, CPU time, or other system resources, more power to you!
Continue reading
Un-Buffering Output
Last year, I wrote about using the standard error device stderr to generate output that can’t be redirected. This technique is often used to send error messages to the console, though I noted how these messages may show up out of sync with standard output. This situation can be resolved, providing you know how to flush the stderr device buffer.
Continue reading
Putting strtol() to the Test
Stop using the atoi() function! Yes, it’s a golden oldie, often my go-to function for converting strings to integers, but it’s weak. The strtol() function, on the other hand, not only converts strings to integers, it can validate input as well.
Continue reading
Peculiarities of the strtol() Function
Imagine my disappointment to learn that the atoi() function, one of the first I learned in C, is actually a macro. I’m horrified. As much as I treasure converting strings to integers, I shall survive this life-changing discovery.
Continue reading