Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Reading a directory file in C
  2. #include <stdio.h>
  3. #include <fcntl.h>
  4.  
  5. int main(int argc, char** argv)
  6. {
  7.         int fd = open(argv[1],O_RDONLY,0 );
  8.         char buf;
  9.  
  10.         printf("%in",fd);
  11.  
  12.         while(read(fd, &buf, 1) > 0)
  13.  
  14.                 printf("%x ", buf);
  15.  
  16.  
  17.         putchar('n');
  18. }