question on opendir, readdir, etc.

Tom Reingold tr at samadams.princeton.edu
Fri Nov 30 05:18:56 AEST 1990


Here is what I've surmised so far.

To use opendir, readdir, etc. on BSD, you include <sys/dir.h>.  This
lets you use a struct defined as direct.  The member d_name is a
character array of size MAXNAMLEN+1 (256).

To use these functions on System V, you include <dirent.h>.  This lets
you use a struct defined as dirent.  Confusingly close.  The member
d_name is a character array of size 1!  Is this for real?  I have a
sample program which works, but I think I'm lucky that trashing the
area after my structure doesn't kill anything vital.

Am I not supposed to use these functions in System V?  If I am, do they
normally work?
--
        Tom Reingold
        tr at samadams.princeton.edu  OR  ...!princeton!samadams!tr
        "Warning: Do not drive with Auto-Shade in place.  Remove
        from windshield before starting ignition."



More information about the Comp.lang.c mailing list