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

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     istgstr.cpp                                              |*/
  4. /*|                                                              |*/
  5. /*|     Class istream                                            |*/
  6. /*|          istream& istream::get( signed char *, int, char )   |*/
  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 characters into an array, up to len chars or delimiter d
  22. istream _FAR & istream::get(signed char* p, int len, char d)
  23. {
  24.     if( ipfx1() )
  25.         {
  26.         signed char* op = p;
  27.         int c = 0;
  28.         while( --len > 0  &&  (c = bp->sgetc()) != d  &&  c != EOF )
  29.             {
  30.             *p++ = c;
  31.             ++gcount_;
  32.             bp->stossc();
  33.             }
  34.         if( c == EOF )
  35.             setstate((p == op) ? (ios::eofbit | ios::failbit) : ios::eofbit);
  36.         }
  37.     else
  38.         setstate(ios::failbit);
  39.  
  40.     *p = 0;     // always terminate with a null
  41.     return *this;
  42. }
  43.