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
Author Archives: dgookin
Parse and Count Words in a String – Solution
The key to making this month’s Exercise work isn’t to know when a word stops, but when the separator characters stop. That’s because words aren’t always separated by single characters.
Continue reading
Parse and Count Words in a String
This month’s Exercise is based on code presented in the June 1 Lesson: split a string into separate words. The difference is that each word you pluck from the string is followed by the number of letters in that word.
Continue reading
Slicing Words from a String
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
Falling Through a Switch-Case Structure
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
Switch-Case Execution
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
The Cryptic Text Encoder
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
Primitive Math – Solution
The solution to this month’s Exercise involves two things. First, knowing how to shift bits and second how to carefully enclose operators in parentheses to get the macros to behave.
Continue reading
Cryptic Text Encoding
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
Primitive Math
In a recent Lesson, I explored upon the idea of creating binary math macros. This technique was popular in Assembly language programs where the processor lacks high order math functions, including basic multiplication and division. In C you can code one-line macros that mimic Assembly’s bit-shifting behavior required to multiply values.
Continue reading