You're probably linking with libucb and didn't read question
6.18. (Readdir in libucb.so wants you to include sys/dir.h,
but many SunOS 4.1.x programs included <dirent.h>, consequently,
you're mixing native <dirent.h> struct dirent with libucb
readdir(). The symptom of this mixup is that the first two
characters of each filename are missing. Make sure you use a
native compiler (default /opt/SUNWspro/bin/cc, which may not be in
your PATH), and not /usr/ucb/cc.