How to create array based output stream, input stream and input/output stream?

Creating array based output stream:

ostrstream constructor is used to create an array based output stream.  Syntax:

ostrstream ost(char *buf, streamsize size, openmode mode=ios::out);

where, buf is pointer to array, ost is the output stream, size is the parameter,

Creating array based input stream:

For linking an input stream to array istrstream constructor is used.


istrstream ist(const char *buf, streamsize size);

Creating array based input/output stream:

strstream constructor is used for creating an array based input/ouput stream.


strstream iost(char *buf, streamsize size, openmode mode = ios::in | ios::out);

where, mode is used to control the operation of the sream.

Leave a Reply