Opening and closing a memory-file is just academic. To make the whole shebang work, you must be able to read and write data.
Continue reading
Category Archives: Lesson
Opening and Closing Memory-Files
To treat a chunk of memory as a file, it must be “opened” and a handle returned for future file reference and interaction. Likewise, the memory-file must be “closed” when you no longer need it. To accomplish these tasks, I’ve crafted the mem_open() and mem_close() functions.
Continue reading
Memory Files
In the Unix environment, everything is a file. For example, you can open the terminal as a file, which I covered in a previous Lesson. But what about memory? Can you open memory as a file? And why would you want to?
Continue reading
The camelCase to snake_case Conversion with Proper Memory Allocation
With all the storage available in a modern computer, it’s easy — and often perfectly okay — to be overly generous when allocating memory. Still, the old coder in me has a lingering desire to save every byte possible. So when it comes to crafting a solution for this month’s Exercise, my desire is to be byte stingy.
Continue reading
A Better camelCase to snake_case Conversion
My solution for this month’s Exercise took some terrible assumptions. First, that the strings are merely output and not stored. Second, that the strings are perfectly formed camelCase and snake_case. In this Lesson, I address the first concern.
Continue reading
Using scanf() to Build a String – Part V
In my code update for last week’s Lesson, I used return statements to send strings back to the main() function. This technique works — only once, even though the strings are declared static in the token() function.
Continue reading
Using scanf() to Build a String – Part IV
I refer to the process of converting special characters into strings as tokenizing. The token is a character or string — a code. This code is translated into something else, which allows the program to deal with complex items in a simple manner.
Continue reading
Using scanf() to Build a String – Part III
Unless the code must run endlessly, such as a program that operates a gas pump, an endless loop isn’t something you want. From last week’s Lesson, I crafted an endless loop to accept single-word input from the scanf() function to build a string. But no string is output because the loop never ends! It’s time to address this situation.
Continue reading
Using scanf() to Build a String – Part II
Trying to salve my frustration with the scanf() function, I decided in last week’s Lesson to try to use scanf() to build a string. Because the function terminates standard input at the first whitespace character (space, tab, newline), the strings input must be stored and the string built in memory.
Continue reading
Using scanf() to Build a String – Part I
The scanf() function is useful for teaching, but it’s a booger. I avoid it outside of demonstration purposes. But it does provide good fodder for training beginning programmers to think about stream I/O.
Continue reading