Advertisement
Guest User

Untitled

a guest
Mar 14th, 2013
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<unistd.h>
  3. #include<fcntl.h>
  4. #include<stdlib.h>
  5. #include<sys/stat.h>
  6. int main(int argc,char *argv[])
  7. {
  8. int i;
  9. struct stat buf;
  10. char *ptr;
  11. for(i=1;i<argc;i++)
  12. {
  13. printf("%s:",argv[i]);
  14. if(stat(argv[i],&buf)<0)
  15. {
  16. printf("stat error");
  17. }
  18. }
  19. if(S_ISREG(buf.st_mode))
  20. ptr="regular";
  21. else if(S_ISDIR(buf.st_mode))
  22. ptr="directory";
  23. else
  24. ptr="unknown";
  25. printf("%s\n",ptr);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement