C++ std::istrstream














































C++ std::istrstream



std::istrstream

Description

The class istrstream reads characters from an array in memory. It uses a private strstreambuf object to control the associated array object. It inherits from basic_istream and therefore can use all the formatted and unformatted input functions. Basically istrstream objects store entire char array in strstream buffer. The typical implementation of istrstream holds only one non-derived data member: an object of type std::strstreambuf. It is defined in the <strstream> header file.



Member Functions

rdbuf() : returns a pointer to the associate strstreambuf (public member function)
str()   : access the output buffer  (public member function) 


Syntax

std::istrstream <object_name> (string literal);
std::istrstream <object_name> (char *s, streamsize n);


Note

istrstream has been deprecated since C++98. std::istringstream and boost::iostreams::array_source are the recommended replacements.



Example Code 1




Output




Example Code 2




Output





Comments