I have two questions when it comes to using the % operator: Is it modulus or modulo? And which value comes first?
Continue reading
Author Archives: dgookin
From ‘A’ and ‘a’ to ‘Z’ and ‘z’
Difficulty: ★ ☆ ☆ ☆
Here’s an easy exercise to try, something for those first learning C programming but also a challenge for experienced users: Output the alphabet A to Z in both upper and lowercase letters. It’s an “easy” exercise only when you don’t explore the possibilities.
Continue reading
Forcing a Decision
Programs often ask questions: yes-or-no and multiple choice. The user must select one of the given options, which I refer to as forcing a decision. Your goal as programmer is to pester the user to input a valid choice.
Continue reading
Returning a Non-Static String
It’s possible to return a string created in a function without declaring it static. This trick requires some understanding of how functions return values. Nerd alert!
Continue reading
Having Fun with the getline() Function
In last week’s post, I updated information I had originally written about the useful getline() function. The topic is worthy of further exploration, specifically with the mechanics behind the function’s internal allocation — and reallocation — of memory.
Continue reading
The getline() Function – Update
Back in early 2015, I wrote about the getline() function, which is a handy way to read a string. I’ve been informed that my post is the top result for a Google search on getline() — and I have an update!
Continue reading
Your Own Version of left-pad() – Solution
Can you write your own left-pad function in C? Would you get so angry that you’d pull it from the Jenga-tower NPM and bring the Internet to its knees? I hope your answer Yes to the first question and No to the second, because your task for this month’s Exercise is to write that function.
Continue reading
Chatting with a Thread
A launched thread can be passed an argument, similar to any function. And the thread can return a value, just like any function. But while the thread runs, options for communications are rather limited.
Continue reading
Your Own Version of left-pad()
Difficulty: ★ ★ ☆ ☆
Padding a string on its left side isn’t that difficult, yet it’s a vital piece of code. To understand why, you need to know that the initialism NPM stands for Node Package Manager. It’s a critical part of the Internet.
Continue reading
Introduction to Pipes
If you’re like me, you’re probably more familiar with the concept of pipes at the command prompt than in a programming environment. Or maybe you don’t care either way. Regardless, both types of pipe are similar forms of communications, but programming pipes seem specifically weird to me.
Continue reading