Tools.h++ Manual
21-156 104011 Tandem Computers Incorporated
21
Note – Variables should not be separated with whitespace. Such whitespace
would be interpreted literally and would have to be read back in as a character
string.
RWpostream
can be interrogated as to the stream state using member
functions
good()
,
bad()
,
eof()
, etc.
Example See RWpistream for an example of how to read back in the results of this
program. The symbol "
o
" is intended to represent a control-G, or bell.
Program output:
5
22.1
-0.05
"A string with\ttabs,\nnewlines and a \x07 bell."
Public constructors
RWpostream(streambuf* s);
Initialize a
RWpostream
from the
streambuf s
.
RWpostream(ostream& str);
Initialize a
RWpostream
from the
streambuf
associated with the output
stream
str
.
#include <rw/pstream.h>
main()
{
// Construct a RWpostream to use standard output:
RWpostream pstr(cout);
int i = 5;
float f = 22.1;
double d = -0.05;
char string[]
= "A string with\ttabs,\nnewlines and a
o
bell.";
pstr << i; // Store an int in binary
pstr << f << d; // Store a float & double
pstr << string; // Store a string
}