The setlocale() function, mentioned in last week’s Lesson, both returns the current locale string and sets a new locale. It’s not necessary to call this function to gather locale details already known to your computer. To pluck out this detail, use the localeconv() function.
Continue reading
Author Archives: dgookin
Don’t be a Stranger to the Locale
A major hurdle in computer science was getting disparate computers to speak with each other. Not verbally, of course, but by exchanging files in compatible file formats. After this task was ironed out, professionals in white lab coats realized the next step was massaging program output to match the user’s language and other local preferences.
Continue reading
Fetching the Search Path
The search path is a list of directories in which the operating system scans for programs. Its purpose is to allow quick access to common programs and system utilities without the necessity of typing a full pathname or changing to the right directory to start an application.
Continue reading
Building a Format String
In the printf() function, the first argument is a format string. It can contain the various percent placeholders to represent values expressed in the remaining arguments. But can one of those arguments also contain placeholders?
Continue reading
Find the Duplicates – Solution
I devised two solutions for this month’s Exercise. The basic solution can be solved in two steps, with a more involved solution using three.
Continue reading
A Curious Thing About Array Notation
It’s nuts. All through your C training when you learned about arrays, you were taught the format: array[x] where array is the name of the array and x is the element number. But this expression can also be written as x[array].
Mind. Blown.
Continue reading
Find the Duplicates
You’ll find multiple reasons to remove duplicates from a series of random numbers. The main reason is that the process or generating random numbers is capable of yielding duplicate values. But more importantly, if your list represents discrete items in the real world, such as playing cards, you can’t really have a duplicate value pop up.
Continue reading
Exit Status Defined Constants
The tradition for successfully exiting a command line program is to use return 0; or, as I write it, return(0);. Zero is the OK value, meaning a program exited cleanly. Other values returned represent specific conditions, not necessarily errors, but information that can be communicated to the operating system or some other program.
Continue reading
The Element Doesn’t Exist
As a mid-level language, C has just as many positives as negatives with regards to accessing memory. One of the biggest negatives is C’s unflinching capability to access data that doesn’t exist.
Continue reading
Variable Length Arrays
The C99 standard added a feature to dimension an array on-the-fly. The official term is variable length array or VLA. And while you might think everyone would love it, they don’t.
Continue reading