Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<unistd.h>
- #include<fcntl.h>
- #include<stdlib.h>
- #include<sys/stat.h>
- int main(int argc,char *argv[])
- {
- int i;
- struct stat buf;
- char *ptr;
- for(i=1;i<argc;i++)
- {
- printf("%s:",argv[i]);
- if(stat(argv[i],&buf)<0)
- {
- printf("stat error");
- }
- }
- if(S_ISREG(buf.st_mode))
- ptr="regular";
- else if(S_ISDIR(buf.st_mode))
- ptr="directory";
- else
- ptr="unknown";
- printf("%s\n",ptr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement