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
Author Archives: dgookin
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
Duplicated Letters
I’ve been working on a program that counts unique words in a text file. It’s an interesting exercise and explores the larger realm of pattern matching. You can try such scanning on a smaller scale by coding a program that counts the frequency of letters within a string. And that task is presented as this month’s Exercise.
Continue reading
To Split a String in C
Have you ever heard a programmer mock the C language? Recently, a C# programmer informed me that C was okay, but “you can’t even split a string in C in less than 20 lines of code.”
Challenge accepted!
Continue reading
Stupid main() Function Tricks
The main() function is the first C language function you learn to write. It’s required. And you probably know that it has arguments, which are culled from the command prompt and made available to the program. So what stupid stuff can you do with main()?
Continue reading
Let’s Be Assertive
I find it fun to debug code. I add various printf() statements to a program to display values and quickly determine what’s going on. This process seems easier than toiling with a debugger.
Continue reading