home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 9.ddi / IOSTRSR1.ZIP / ISTIGN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.2 KB  |  42 lines

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     filename - istign.cpp                                    |*/
  4. /*|                                                              |*/
  5. /*|     Class istream                                            |*/
  6. /*|          istream& istream::ignore( int, int )                |*/
  7. /*|                                                              |*/
  8. /*[]------------------------------------------------------------[]*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1990, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18. #include <ioconfig.h>
  19. #include <iostream.h>
  20.  
  21. // extract and discard n chars, or through delimiter, whichever is first
  22.  
  23. istream _FAR & istream::ignore(int n, int d)
  24. {
  25.     if( ipfx1() )
  26.         {
  27.         int c = 0;
  28.         while( --n >= 0  &&  (c = bp->sgetc()) != EOF )
  29.             {
  30.             ++gcount_;
  31.             bp->stossc();
  32.             if( c == d )
  33.                 break;  // we DO consume the delimiter
  34.             }
  35.         if( c == EOF )
  36.             setstate(ios::eofbit);
  37.         }
  38.     return *this;
  39. }
  40.  
  41.  
  42.