Name
istrstream class — Input character array streams
Synopsis
class istrstream: public istream { public: explicit istrstream(const char* str); explicit istrstream(char* str); istrstream(const char* str, streamsize n); istrstream(char* str, streamsize n); strstreanbuf* rdbuf( ) const; char* str( ); };
The istrstream
class
represents an input string stream. To construct an istrstream
, pass a character array (with
an optional size). You can then read from the string stream just as
you would from any other input stream.
The following are the methods of istrstream
:
explicit
istrstream
(const char* str)
explicit
istrstream
(char* str)
Initializes an input string stream by constructing an internal stream buffer as
strstreambuf(str
,0)
and passing the address of the stream buffer to the base-class constructor foristream
.explicit
istrstream
(const char* str, streamsize n)
explicit
istrstream
(char* str, streamsize n)
Initializes an input string stream by constructing an internal stream buffer as
strstreambuf(str
,n)
and passing the address of the stream buffer to the base-class constructor foristream
.strstreambuf*
rdbuf
( )
const
Returns a pointer to the internal
strstreambuf
object.char*
str
( )
Returns the internal string,
rdbuf( )->str( )
.
See Also
ostrstream class,
strstream class, strstreambuf class, istream
in <istream>
, istringstream
in <sstream>
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.