The challenge for this month’s Exercise is to write the charcount() function, which returns the number of characters in a string. The character matches exactly, so don’t worry about checking uppercase and lowercase differences.
Continue reading
Category Archives: Solution
From camelCase to snake_case – Solution
The challenge for this month’s Exercise is to convert a name from camelCase to snake_case and vice-versa. As usual, several approaches provide a possible solution. The directions were to output the results and not store them, so my solution is rather simple.
Continue reading
The Sum of the Integer’s Digit – Solution
The challenge for this month’s Exercise is to tally the digits in an integer, reporting the sum. You must use math and not cheat by looking at the old solution, which I didn’t. Promise.
Continue reading
Swapping Variables – Solution
This month’s Exercise challenges you to swap two variables’ values without using a third variable. It’s a solution widely available on the Internet, but your job is to figure out the technique without looking elsewhere.
Continue reading
Yesterday – Solution
The challenge for this month’s Exercise is to output yesterday’s date: the day of the week, day of the month, month, and year. It’s not as complex as it could be, though keep in mind that any code that outputs the proper result is valid.
Continue reading
Counting the Non-ASCII Bytes – Solution
Several items are noteworthy for this month’s Exercise , with the biggie being how to detect a non-ASCII character. The secret involves a wee bit of type conversion.
Continue reading
Merging Arrays – Solution
This month’s Exercise is about coding a merge() function, which swallows two arrays and generates a third as output. The new array is “zippered” from the original arrays, alternating values from each.
Continue reading
A Compact for Loop – Solution
I hope you were able to cram a lot of expressions into a for loop statement, which is the challenge for this month’s Exercise. Even if you know this trick, it’s important to understand it’s limitations — which is something I discovered during my research.
Continue reading
How Big is That File? – Solution
The challenge for this month’s Exercise is to return a file’s size without using the stat() function. My goal is to get you to think about various file tools and how they can be useful beyond their intended purpose.
Continue reading
Quick Sorting Structures – Solution
The task for this month’s Exercise is to extract a structure member from a void pointer for use in the quick-sort compare() function. This isn’t a solution you can readily find on the Interwebs.
Continue reading