Advertisement
Tobiasz931

upośledzony ls -l w C

Dec 11th, 2012
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "sys/types.h"
  3. #include "dirent.h"
  4. #include "errno.h"
  5. #include "string.h"
  6. #include "stdlib.h"
  7. #include "sys/stat.h"
  8. int main(int argc, char *argv[]){
  9. struct stat st;
  10.     DIR *pDIR;
  11.     int size;
  12.     struct dirent *pDirEnt;
  13.     pDIR=opendir (".");
  14.     if(pDIR==NULL){
  15.         fprintf(stderr, "%s %d:opendir() failed (%s)\n", __FILE__, __LINE__,strerror(errno));
  16.         exit(-1);}
  17.     pDirEnt=readdir(pDIR);
  18.     while(pDirEnt !=NULL){
  19.         printf("%s ", pDirEnt->d_name);
  20.         stat(pDirEnt->d_name, &st);
  21.         size = st.st_size;
  22.         printf("%d bajtow \n", size);
  23.         pDirEnt=readdir(pDIR);}
  24.     closedir(pDIR);
  25.     return 0;
  26. }
  27.  
  28. //ls -l
  29. //ls -R
  30. // +3 dowolne inne opcje
  31. //ls -l /etc podanie katologu wywołania
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement