Being the ancient and venerable programming language it is, C lacks the associative array data type. This type of array is found in other languages, and it can be awkwardly simulated in C.
Continue reading
Category Archives: Lesson
Pairs of Arrays
I enjoy studying foreign languages. A tool like Google Translate comes in handy, but it’s not perfect. That’s because computers translate words and phrases, but not the living, spoken language. Regardless, I thought I’d give language translation a stab, which got me into the topic of exploring arrays.
Continue reading
The Improved nano_delay() Function (I Hope)
Last week’s Lesson explored using the clock_gettime() function to pause program execution for a given number of nanoseconds. The code, however, contains a flaw that may render an inaccurate result.
Continue reading
Your Own Time Delay Function
I’ve written about my own delay() function, which uses processor clock ticks to calculate a time delay in milliseconds. Thanks to the clock_gettime() function, I can write a new time-delay function that operates from nanoseconds — or close to it. I hope.
Continue reading
Programming with Nanoseconds
From last week’s Lesson, the clock_gettime() function returns values in both time_t (Unix Epoch) seconds as well as nanoseconds. This rich variety makes the function quite useful for coding time-critical details where values less than a second are desired.
Continue reading
Checking the Time
I tend to keep the lessons on this blog specific to the standard C library, C99 release. Yet every so often a newer function draws my attention, which may not be standard but can still be useful. Case in point is the clock_gettime() function, which subscriber M.Stumpfl mentioned in a previous post.
Continue reading
What the Heck is That Thing?
I just moved to a new computer. The process involved taking all my personal programs and re-compiling them for the new system. It took a while, but fortunately everything works with my various programs doing their necessary jobs. That is, unless I see a weirdo error upon compiling one of those golden oldies. On such error I saw made me wonder what they heck I was doing in my code.
Continue reading
The Final Output to HTML Code
The final update to the sconvert function includes translating characters &, <, and > for proper HTML output. With this update to the code from last week’s Lesson, the conversion filter is complete and can be used to translate C program text output into HTML code that I can easily post on the web.
Continue reading
Properly Padding Spaces and Tab Widths
The task for last week’s Lesson was to convert tabs as well as spaces. The problem is that tab stops aren’t considered: On the terminal, a tab character generates a variable number of spaces based on where the next tab stop position is located. It isn’t a fixed value.
Continue reading
Properly Padding Spaces – and Tabs
As you can tell by the post title, part of the sconvert program I missed is to convert tab characters into HTML spaces. Like spaces, tabs output blanks that must be converted to the code for proper output on a web page.
Continue reading