Your task for this month’s Exercise is to take a timestamp string and move values from inside a string (characters) into a structure. It’s not an easy exercise, and it doesn’t have a single, best solution.
Continue reading
Category Archives: Solution
Highlight a Chunk of Text – Solution
Your task for this month’s Exercise is to code a text-processing routine that interprets the ^ character as a toggle for all-caps output. This challenge can be difficult, depending on how you interpret the toggle.
Continue reading
Increasing Brightness – Solution
The challenge for this month’s Exercise is to fill a cup without overflowing it. That cup is an unsigned char value, which goes only to 255 maximum. If your goal is increase the value of an unsigned char variable by 10 percent, any value over 255 - (255/10), or 220, must be set to 255.
Continue reading
Oscillation – Solution
For my solution to this month’s Oscillation Exercise I created a toggle variable. This variable switches between 1 and -1. It sets the direction for the cascading values.
Continue reading
Swapping Strings – Solution
This month’s Exercise involves swapping elements between two string arrays. A number of solutions exist (as always), but because the “strings” are really pointers, the solution can be very specific. Yes, you just might have to use that dratted ** notation. Brace yourselves.
Continue reading
Swapping Arrays – Solution
The two functions required from this month’s Exercise are show_arrays() and swap_arrays(). They’re not that difficult to code, meaning that you don’t need to use the dratted ** notation or perform any special tricks. Here’s how I solved the problem:
Continue reading
Filename Extractor – Solution
When I see a problem such as finding a filename in a pathname, one of the first things I think of are regular expressions. For this month’s Exercise, however, that’s not the solution I coded.
Continue reading
Right String – Solution
For this month’s Exercise, I offer both a string function solution as well as a solution that uses pointers. As you can guess, I thought of the string method first, which is where most programmers would run to avoid the dratted topic of pointers.
Continue reading
The URL Decoding Filter – Solution
Unwinding percent-encoding involves three steps:
- Pass-through the unchanged characters.
- Change
+back into a space. - Decode the percent strings, which is the most involved process.
The URL Encoding Filter – Solution
A URL filter isn’t that difficult to code, once you know the rules. I’m sure you can concoct something clever or obfuscated in the C language, but I chose to use a clutch of if/else if/else statements to process input and generate output.
Continue reading