Thanks to Mr. Spock (and God bless you, Mr. Nimoy!), many people think of Chess when they think of computer programming. Unlike mankind’s favorite Vulcan, coding your own computer chess game would be a tremendous undertaking. Even so, you can start with the basics and write a program that outputs a chessboard.
Continue reading
Inside the Quicksort
The Internet is littered with plenty of good explanations of how the quicksort works. The definition at Wikipedia graphically illustrates the process, which is commonly called “divide and conquer.” I’ve stolen the Wikipedia illustration and placed it into Figure 1.
Continue reading
The Quicksort
Computers excel at searching and sorting. That, and they can occasionally screw up a phone bill.
Continue reading
Sorting It All Out
Computers are good at performing repetitive tasks; doing the same boring nonsense over and over. Two great examples are searching and sorting.
Continue reading
Pattern Manipulation – Solution
This month’s Exercise was to create a cycle of numbers, values that repeat within a certain range. Of all the Exercises presented so far on this site, this one probably has the greatest number of solutions.
Continue reading
Other Ways to Fetch the CWD
In last week’s Lesson I mentioned the constant, MAXPATHLEN. Like PATH_MAX, it returns the size of the maximum number of characters allowed in a pathname. Unlike PATH_MAX, however, MAXPATHLEN is defined in the sys/param.h header file, not limits.h.
Continue reading
Pattern Manipulation
You see them all the time, mostly as “busy” gizmos. They are animations that spin or dance to deceive you into believing that the software is really doing something. But they’re merely animations. In fact, they’re very simple animations that require practically effortless coding.
Continue reading
Fetching the Current Path
The C library hosts many file and directory management functions. They’re all pretty standard, no matter which operating system you use. What isn’t standard, however, is the size of a pathname. That value plays an important role if you’re to properly allocate memory to store directory information.
Continue reading
Finding the PATH_MAX
Your code may be compiled on a PC, Mac, Linux system, or even some microcontroller. In each case, it helps to know the environment before you code. You can guess, but it’s better to use the defined constants — if they’re available to you.
Continue reading
Know Your Limits
Back when I was a young, budding nerd, I popped off how there are always 8 bits in a byte. A much wiser programmer raised an eyebrow and quizzed me, “Always?”
Continue reading