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
Author Archives: dgookin
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
The Reversing Words Filter
Difficulty: ★ ★ ★ ☆
A few months back, this blog’s monthly Exercise was to write a filter to reverse all text input. No matter how much text floated in, the filter gobbled it all up and spewed it back in reverse order. This month’s challenge is similar, but on a smaller scale.
Continue reading
The Story of the Undefined Reference Error
Let me be blunt: If you haven’t yet seen an undefined reference error, you truly aren’t a C programmer. In fact, the more of these messages you see, the longer you’ve been coding in C. Undefined reference errors are a badge of honor.
Continue reading