Exploring a folder tree — I mean directory tree — is a procedure found in many file and media utilities. From an original directory, you scan the list of files looking for a subdirectory. When it’s found, you open it and recursively continue the scan.
Continue reading
Author Archives: dgookin
Pulling a Directory
O how well I remember DOS. It wasn’t Unix, but it cribbed from Unix heavily. One of the popular DOS commands was DIR, which was like the shell command ls, but more primitive. A typical DOS directory listing looked something like this:
Continue reading
Shuffle That Playlist – Solution
The solution to this month’s Exercise is similar to code I’ve presented in my books and in this blog with regards to randomly drawing from a fixed set of elements. Yet it has an extra level of complexity.
Continue reading
Shuffle That Playlist
Recently, I created a playlist of songs on a certain online subscription service. I chose to shuffle the tunes, but found that one song in particular played more often than the others. My immediate thought was, “Why can’t the programmers design a shuffled playlist that doesn’t overplay the same song”? Rather than email the programmers, I thought I’d present the puzzle as this month’s Exercise.
Continue reading
Directory Entry File Types
Not every file listed in a directory is the same. Some entries represent other directories, subdirectories, for example. To determine which entries are mere mortal files and which are directories, you must examine the file type.
Continue reading
Reading a Directory
I’m refusing to call it a “folder.” That nonsense gained popularity with the Macintosh and then Windows. Before then, it was a directory, a list of files stored on media. Special C language functions are available to read and manipulate directories, which helps your programs manage files and do other fun file stuff.
Continue reading
What Evil Lurks in a Header File . . . ?
As a beginner, your first exposure to a header file is most likely <stdio.h>, which you understand is necessary for some reason. Then you may confuse the header file with the library, which is common but wrong. And you may even dabble with your own header files. Beyond that, few tutorials bother to mention any necessary details about what should go into a header file and when it’s necessary . . . until now.
Continue reading
Eliminating the Blanks
My solution for this month’s Exercise generated a list of duplicated letters in a string. The list also includes blank lines. It’s possible to prevent the blank lines from being displayed, but to do so requires extra programming kung fu.
Continue reading
Duplicated Letters – Solution
The challenge for this month’s Exercise is to write code that counts repeating letters in a string. For example, the string “Hello, this is a test” repeats the letters T and S three times, letters E, H, I, and L twice, and the letters A and O appear only once.
Continue reading
Ten C Programming Mistakes
I’m certain that more than 10 C programming mistakes are common, but for some reason people enjoy lists with 10 items. My list of Ten C Programming Mistakes isn’t a top-ten list, so nothing is ranked. These are just a collection (cut off at 10) of the problems and issues I find most frequently when coding in the C language.
Continue reading