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

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 0.25 KB  |  hits: 20  |  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. Interaction of POSIX file descriptors and C FILEs
  2. FILE* f1 = fopen("a.txt", "r");
  3. int fno = fileno(f1);
  4. FILE* f2 = fdopen(fno, "r");
  5.  
  6. // is it true?
  7. assert(fileno(f2) == fno);
  8.  
  9. // does it close only f1 or f2 too?
  10. fclose(f1);
  11. fgetc(f2); // valid?