For this month’s Exercise, my solution to the scramble() function requires a second array. You could code a scramble() function without using a second array (or storage buffer), swapping individual characters within the string, but I chose not to.
Continue reading
Author Archives: dgookin
When Passing a String to a Function, Be Careful That You Don’t . . .
Passing a string to a function? Check!
Passing an array of strings to a function? Watch out!
Continue reading
Scramble a String
Difficulty: Hard
Most functions are nice to strings. They manipulate the characters in a useful or clever way, returning an important value or an updated version of the text. But not every string function needs to be so kind, such as the one you write for this Exercise.
Continue reading
Manipulating a String in a Function
You have two choices when modifying a string in a function: You can modify the string directly or you can create a new string and return it. Either way, a new string is created based on the old.
Continue reading
Passing Strings to a Function
Despite teaching the C language, I still find myself at odds with pointers. Specifically, it’s the double pointers that remind me of my mortality. I found myself getting into the double pointer polka recently when I tried to work with an array of strings, passing each one individually to a function. O! The pain!
Continue reading
Negative Array Elements
I enjoy it when an experienced coder reviews my stuff. I’m happy with the feedback, and occasionally they toss me a bone. This time it was a rather obscure bone, but I see the point: Avoid using negative array elements.
Continue reading
A Handy ASCII Table – Solution
My ASCII table program had several iterations. It’s easy to get carried away, but it’s also easy to be too skimpy on the information. This month’s Exercise is based on my current ASCII program, which has evolved over the years.
Continue reading
Characters, Values, and Playing with Your Brain
I’ve messed with characters as values quite a few times in my code. Keeping in mind that the char data type is really a tiny integer value, you can perform all kinds of tricks — stuff that drives non-programmers crazy.
Continue reading
A Handy ASCII Table
Difficulty: Easy
Every coder needs an ASCII table. Even back in the old days, when I memorized such things as the Escape character was equal to 27 decimal, 0x1b hex, and had the keyboard shortcut ^[, I would glance at the ASCII table poster hanging on the wall to confirm that I was using the proper values in my code. And the poster looked cool.
Continue reading
Reading strings with the sscanf() Function
I’m not a fan of the scanf() function. It’s an input function, quick enough to toss out there for a beginner to write a (somewhat) interactive programs. But the function itself is horrid, with complex arguments and dubious results.
So imagine my delight at finding its companion function, sscanf().
Continue reading