home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / FLUSHALL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.6 KB  |  52 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - flushall.c
  3.  *
  4.  * function(s)
  5.  *        flushall - clears all buffers
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #include <stdio.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name        flushall - clears all buffers
  23.  
  24. Usage        int flushall(void);
  25.  
  26. Prototype in    stdio.h
  27.  
  28. Description    clears all buffers associated with open input streams,
  29.         and writes all buffers associated with open output streams
  30.         to their respective files.  Any read operation following
  31.         flushall reads new data into the buffers from the input
  32.         files.
  33.  
  34. Return value    the number of open input and output streams
  35.  
  36. *---------------------------------------------------------------------*/
  37. int flushall(void)
  38. {
  39.     register FILE    *fp;
  40.     register int    Nb;
  41.     int        Cpt;
  42.  
  43.         for (Cpt = 0, Nb = FOPEN_MAX, fp = _streams; Nb--; fp++)
  44.         if (fp->flags & _F_RDWR)
  45.         {
  46.             fflush(fp);
  47.             Cpt++;
  48.         }
  49.  
  50.     return(Cpt);
  51. }
  52.