Click on the banner to return to the class reference home page.

istrstream


istrstreambasic_istreambasic_iosios_base

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <strstream>
class istrstream 
: public basic_istream<char>

Description

The class istrstream provides functionality to read characters from an array in memory. It uses a private strstreambuf object to control the associated array object. It inherits from basic_istream<char> and therefore can use all the formatted and unformatted input functions.

Interface

class istrstream : public basic_istream<char> {

 public:

  typedef char_traits<char>             traits;
    
  typedef char                         char_type;
  typedef typename traits::int_type    int_type;
  typedef typename traits::pos_type    pos_type;
  typedef typename traits::off_type    off_type;

  explicit istrstream(const char *s);
  istrstream(const char *s, streamsize n);
  explicit istrstream(char *s);
  istrstream(char *s, streamsize n);

  virtual ~istrstream();

  strstreambuf *rdbuf() const;

  char *str();

};

Types

char_type
int_type
off_type
pos_type
traits

Constructors

explicit istrstream(const char* s);
explicit istrstream(char* s);
explicit istrstream(const char* s, streamsize n);
explicit istrstream(char* s, streamsize n);

Destructors

virtual ~istrstream();

Member Functions

char* 
str();
strstreambuf* 
rdbuf() const;

Examples

//
// stdlib/examples/manual/istrstream.cpp
//
#include<iostream>
#include<strstream>

void main ( )
{
  using namespace std;   

  const char* p="C'est pas l'homme qui prend la mer, ";
  char* s="c'est la mer qui prend l'homme";

  // create an istrstream object and initialize
  // the underlying strstreambuf with p
  istrstream in_first(p);
  
  // create an istrstream object and initialize
  // the underlying strstreambuf with s
  istrstream in_next(s);

  // create an ostrstream object
  ostrstream out;

  // output the content of in_first and
  // in_next to out
  out << in_first.rdbuf() << in_next.str();
  
  // output the content of out to stdout
  cout << endl << out.rdbuf() << endl;

  
  // output the content of in_first to stdout
  cout << endl << in_first.str();

  // output the content of in_next to stdout
  cout << endl << in_next.rdbuf() << endl;

}

See Also

char_traits(3C++), ios_base(3C++), basic_ios(3C++), strstreambuf(3C++), ostrstream(3C++), strstream(3c++)

Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Annex D Compatibility features Section D.6.2

Standards Conformance

ANSI X3J16/ISO WG21 Joint C++ Committee


©Copyright 1996, Rogue Wave Software, Inc.