desdemona

lab so 11.12 prawiels

Dec 11th, 2012
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 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.  
  8. int main(int argc, char *argv[])
  9. {
  10.     DIR *pDIR;
  11.     struct dirent *pDirEnt;
  12.     pDIR=opendir(".");
  13.     if(pDIR==NULL)
  14.     {
  15.         fprintf(stderr, "%d: opendir() failed (%s)\n", __FILE__, __LINE__, strerror(errno));
  16.         exit(-1);
  17.     }
  18.     pDirEnt=readdir(pDIR);
  19.     while(pDirEnt!=NULL)
  20.     {
  21.         printf("%s\n", pDirEnt->d_name);
  22.         pDirEnt=readdir(pDIR);
  23.     }
  24.    
  25.     close(pDIR);
  26.     return 0;
  27.    
  28. }
Advertisement
Add Comment
Please, Sign In to add comment