Sending text to standard output is something you learn with your first C program. The common functions are putchar(), puts(), printf(), and so on. When you explore file access, you’ll find familiarity in those functions because they’re quite similar to the standard I/O functions.
Continue reading
Category Archives: Lesson
A File Outta Nowhere
I had such a struggle with file I/O when I first learned computer programming. I knew what a file was and how to create it in an application. With computer programming, however, you enter a lower-level realm that requires more knowledge of file access.
Continue reading
Fun with Preprocessor Names
Your probably familiar with the #include and #define preprocessor directives. You may know a few more, which come in handy for certain coding issues. I have a page on this blog, which goes over some of the common directives, but it doesn’t cover them all. Specifically, it doesn’t cover the preprocessor names.
Continue reading
Recursively Plowing a Directory Tree
The code to recursively plow a directory tree presented in last week’s Lesson could be improved upon. Primarily, it relies upon the .. shortcut to jump back to the parent directory. This method works only some of the time.
Continue reading
Directory Spelunking
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
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
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