Expanding an allocated buffer is something you can do with a pointer, but not with an array. This flexibility is why I encourage all C language students to understand and use pointers, though it doesn’t make the concept nay less onery.
Continue reading
The Ever-Expanding Pointer Array
Perhaps the most difficult part of learning C is understanding and coding pointers. Even when you have a grip on things, it helps to keep fresh and practice new and utterly obnoxious ways to play with pointers.
Continue reading
Heron’s Formula – Solution
The challenge for this month’s Exercise is to code Heron’s Formula. This geometric magic calculates the area of a triangle given the length of each of its three sides.
Continue reading
Coding a Better stringcopy() Function
From last week’s Lesson, the task is to code a safer, better version of the strcpy() function. The goals are to check buffer size, report an overflow or underflow (buffer is too big or too small), and potentially confirm whether data is overwritten. Such a program is often used as a test when applying for a C programming job.
Continue reading
Heron’s Formula
Difficulty: ★ ★ ☆ ☆
The only aspect of math I enjoyed in school was geometry. Trigonometry was a close second. I found the study fascinating and did well; I received a B in that class as opposed by my usual C- or D.
Continue reading
Copying Strings
The C language has string manipulation functions, but they’re tepid. In fact, the C23 update includes even more functions to duplicate strings and to stick them together. These actions are simple in other languages, but create such a problem for C that coding a string copying function is often a skill you must demonstrate when applying for a C programming job.
Continue reading
Finding Those Pesky Null Characters!
You’ve crafted a brilliant function, ensuring that it properly processes words and generates needed output. Is the code perfect? Well, it looks perfect. But how do you know for certain?
Continue reading
More Array, More Decay
I’ll be blunt: If you want to pass an array to a function, or have a function return an array, just give up now and use pointers. It’s a far easier operation, and it would save me the bother of having to write this post to further discuss the topic of array decay.
Continue reading
The Reversing Words Filter – Solution
The task for this month’s C programming Exercise is to code a filter that reverses single words. As a filter, the code deals with standard input and output, but it must store this input in word-sized chunks for the reversing process to work.
Continue reading
The Trouble with Array Decay
Array decay has nothing to do with too much sugar in your code or poor brushing habits. No, it’s a hot topic in C programming, and a source of confusion.
Continue reading