What is wrong with this code ?

G.Narotham Reddy nrg at nsscb.UUCP
Sun Dec 10 03:46:12 AEST 1989


#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

main(argc,argv)
int argc;
char *argv[];
{
struct stat nfile;
stat(argv[1], &nfile);
if (nfile.st_mode & S_IFMT == S_IFREG) 
printf("%s regular file\n", argv[1]);    
else if (nfile.st_mode & S_IFMT == S_IEXEC) 
printf("%s executable\n", argv[1]);    
else if (nfile.st_mode & S_IFMT == S_IWRITE) 
printf("%s writable\n", argv[1]);    
else if (nfile.st_mode & S_IFMT == S_IREAD) 
printf("%s readable\n", argv[1]);    
else if (nfile.st_mode & S_IFMT == S_IFDIR)
printf("%s dir\n", argv[1]);    
}


Thanks
-- 
_________________________________________________________________________
Narotham Reddy    reddy at attctc.Dallas.TX.US	 reddy at nucleus.mi.org
			       reddy at pooh.att.com
-------------------------------------------------------------------------



More information about the Comp.lang.c mailing list