The task for this month’s Exercise is to return the month number for a time_t value. Effectively you extract the year and month, do some math, presto. Could it be this easy?
Continue reading
Author Archives: dgookin
More Efficient Prime Number Calculations
A long time ago, I looked at one of my prime number hunting programs, such as the one demonstrated in last week’s Lesson. I thought, “How can I make this program more efficient?” It’s something all programmers should do.
Continue reading
Calculating Months
I recently updated my Wambooli website’s front page to show only recent blog posts. I don’t regularly maintain the Wamblog any longer, so it was disappointing for me to see “recent posts” from ages ago. Therefore, I did a little coding to ensure that only recent posts appear or nothing.
Continue reading
Generating Prime Numbers
Numbers with only two factors, one and themselves, are prime. One way to discover which numbers are prime in a computer program is to plow through all the factors.
Continue reading
A Matter of Factors
Prime numbers are a popular topic in computer programming. It surprised me that I hadn’t yet plumbed primes on this blog, so I’m past due. And forget about the nerdy aspect of prime numbers. Of all the concepts in mathematics, primes are something most people understand.
Continue reading
String Versions of ctype Functions
The ctype functions are marvelous for single character manipulation and testing. Often, however, the functions appear in a loop so that they can be applied to an entire string. So why not write a string-based ctype function? Of course, that’s what I did.
Continue reading
Is This Unix?
In the beginning, Ken Thompson, Dennis Ritchie, and others created Unix. And it was good. Then came the varieties and variants: BSD, System V, and eventually Linux. These are all similar operating systems, not identical, but with a common root and familiar features. You can’t call them all “Unix,” so over time various standards and terms have been developed.
A term that frequently pops up when ruminating over the various Unixes and Linux distros, is POSIX.
Continue reading
A Cumulative Total – Solution
I find it odd that the recursive solution for this month’s Exercise is far shorter than the non-recursive version. Yet, it has an elegance that’s evident in lots of recursive code examples.
Continue reading
The Terminal Has a Name
In Linux and Unix, the terminal is assigned a name. Specifically, it’s the name of a file located in the /dev
directory. This configuration is necessary because the operating system treats all devices as files. Like a file, you can read and write from the terminal; it’s an I/O device. To get started, you must know the current terminal’s filename.
Continue reading
A Cumulative Total
I remember the first time I heard the puzzle: If you’re paid a penny on the first day, doubled on the second day, and doubled every day after, by the end of the month you’d be a millionaire many times over. This concept is mind boggling.
Continue reading