Sample Exercises
Filesystem: Report
Write a program that displays information about the files and/or directories listed on the command line. For each word on the command line, check if it is a file or directory, and do the following:
If it is a file, display the file size and how long ago it was most recently modified, like this:
foo.txt contains 12345 bytes and was last modified 1.5 days ago.
If it is a directory, then use opendir and readdir to read it, and display the names of each file or directory therein and whether it is a file or directory. (Do not recursively display this information about the contents of sub-directories...) Example:
. is a directory .. is a directory foo.txt is a file fsreport.plx is a file
Solution for Report
SolutionLast updated:
Copyright © 1995-2008 William R. Ward dba Bay View Training. All Rights Reserved. “Bay View Training”, “Bay View Consulting Services”, “Bay View Software”, the sailboat logo, and the domain name “bayview.com” are trademarks and/or service marks of William R. Ward dba Bay View Training. For more information, contact training@bayview.com
