1 2 3 4 5 6 7 8 9

String Steams

*

The istrstreamand ostrstreamclasses can be used to read and write from character arrays, these classes operate in the same way as the sscanfand sprintffunctions in stdio

The first parameter to their constructors is a pointer to the character array, and the second parameter is the size of the array. The array must be allocated before the constructor is called

In the case of an ostrstream, an end-of-filecondition is signalled when the end of the string is reached. An ostrstreamwill not overwrite the end of the character array that it is passed

The istrstream class expects a NULL terminated character string. It extracts characters from this string as it reads. Again an end of file will be signalled when the end of the string is reached

All the istreamand ostreamfunctions can be performed on these classes

*

*

*

*

To summarize:
#include <strstream.h>
#include <iostream.h>
#include <fstream.h>

23 March, 1998

// useful for read/write arrays // cin and cout -- also cerr // reading/writing files

Page 9