R1D25 The C Programming Language

| programming |

I realize I am kind of all over the map, but I learn best when I am doing 50 things at once. Ast least that is what I tell myself. It could also be the reason why I am a master of none. :)

I’ve struggled to get through K&R for a while. I figured I could spend the next few days of 100 days of code to make my way through this book before making my way back to the C# course which was starting to make my head hurt a little bit.

Of course, this turned out to not be the best idea because I spent way too much time trying to solve a seemingly very simple problem in C. It’s a problem I’ve gotten stuck on several times as I have made my way through this book in the past.

The problem is:

Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
This seems stupidly simple. But I can't seem to figure it out, and I refuse to google for the solution just yet.

I tried an approach using getchar() and putchar() but my output either contains no spaces, a jumble of words, or something else. I’ll take another crack at this tomorrow and might resort to either pulling out gdb to step through my stupidly simple code, or go figure out the internals of how getchar() and putchar() work in the standard library.

By the end of this, I will know more about these two functions than I ever wanted to.

Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.

Check out some more stuff to read down below.

Most popular posts this month

Recent Favorite Blog Posts

This is a collection of the last 8 posts that I bookmarked.

Articles from blogs I follow around the net

this is such a painful loss. my heart is broken.

“The most important things are the hardest things to say. They are the things you get ashamed of, because words diminish them — words shrink things that seemed limitless when they were in your head to no more than living size when they’re brought out. But…

via WIL WHEATON dot NET December 15, 2025

Ribbon Finance suffers $2.7 million exploit, plans to use "dormant" users' funds to repay active users

Ribbon Finance, which has partially rebranded to Aevo, has lost $2.7 million after attackers exploited a vulnerability in the smart contract for legacy Ribbon vaults that enabled them to manipulate oracle prices and withdraw a large …

via Web3 is Going Just Great December 15, 2025

Pluralistic: Break up bad companies; replace bad union bosses (15 Dec 2025)

Today's links Break up bad companies; replace bad union bosses: Labor should be fixed, capital should be vanquished. Hey look at this: Delights to delectate. Object permanence: "Star Island"; "Mediactive"; Afraid of solar; Well-Armed P…

via Pluralistic: Daily links from Cory Doctorow December 15, 2025

Generated by openring