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

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     istechp.cpp                                              |*/
  4. /*|                                                              |*/
  5. /*|     Class istream                                            |*/
  6. /*|          istream& istream::operator>> ( signed 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. #include <ctype.h>
  21.  
  22. istream _FAR & istream::operator>> (signed char* p)
  23. {
  24.     if( ipfx0() )
  25.         {
  26.         signed char* op = p;
  27.         int c = 0;
  28.         int len = width(0); // <=0 means no limit
  29.         while( --len  &&  (c = bp->sgetc(), ! isspace(c))  &&  c != EOF )
  30.             {
  31.             *p++ = c;
  32.             bp->stossc();
  33.             }
  34.         if( c == EOF )
  35.             setstate((p == op) ? (ios::eofbit | ios::failbit) : ios::eofbit);
  36.         }
  37.     *p = 0; // always terminate with a null, even if nothing was read,
  38.             // per AT&T ISTREAM(3C++), May 18, 1989, p. 3
  39.     return *this;
  40. }
  41.  
  42.  
  43.