Assignment #1: Programming in C, structs, and Pointers

Write a program that outputs the names and sizes of all files in a directory (or directories) (and by implication, files in a subdirectory) that are larger than a size specified on the command line.

You should be able to run your program from the command line by using

assign1 size dir1 dir2 dir3 ...
If there are no directories specified, use ".". Use recursion to get to the subdirectories.

You will need to grab dirent.h if you are working on some Windows systems.

Highlights

You will need to use the following routines:
DIR *opendir( char *dirname );          // dirent.h
struct dirent *readdir( DIR *dp );      // dirent.h
void closedir( DIR *dp );               // dirent.h

sprintf( char [], const char *, ... );  // stdio.h
int stat( char *, struct stat * fp );   // stat.h
   // return code is non-zero if failure

S_IFMT and S_IFDIR for mask and directory pattern
Here are the structs:
typedef struct dirent
{
    char d_name[NAME_MAX + 1];

    ...
} dirent;

typedef struct DIR
{
    char          *dirname;                    /* directory being scanned */
    dirent        current;                     /* current entry */
    int           dirent_filled;               /* is current un-processed? */

} DIR;


struct stat
{
    _dev_t st_dev;
    _ino_t st_ino;
    unsigned short st_mode;
    short st_nlink;
    short st_uid;
    short st_gid;
    _dev_t st_rdev;
    _off_t st_size;
    time_t st_atime;
    time_t st_mtime;
    time_t st_ctime;
};