Constructors

Creates an array based stream for input.

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

The istrstream constructor is overloaded to accept a dynamic or pre-allocated character based array for input. It is also overloaded to limit the size of the allocation to prevent accidental overflow.

Listing: Example of usage.
#include <iostream>
#include <strstream>

char buf[100] ="double 3.21 string array int 321";   

int main()
{
   char arr[4][20];
   double d;
   long i;

   istrstream istr(buf);
   istr >> arr[0] >> d >> arr[1] >> arr[2] >> arr[3] >> i;
   cout << arr[0] << " is " << d << "\n"
      << arr[1] << " is " << arr[2] << "\n"
      << arr[3] << " is " << i << endl;
   return 0;
}

Result:

  double is 3.21
  string is array
  int is 321