Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
istrstream.cpp
Go to the documentation of this file.
1
29#include <iostream> // for cout
30#include <strstream> // for strstream
31
32#include <examples.h>
33
34
35int main ()
36{
37 // create two constant istrstream objects and initialize their
38 // underlying strstreambufs with string literals; the objects
39 // do not create copies of the literals but use them directly
40 // for efficiency
41 std::istrstream a ("Ce n'est pas l'homme qui prend la mer, ");
42 std::istrstream b ("c'est la mer qui prend l'homme.");
43
44 // create a dynamic strstream object
45 std::strstream out;
46
47 // output the contents of the streams into out
48 out << a.rdbuf () << b.str () << '\n';
49
50 // output the contents of out to standard output
51 std::cout << out.rdbuf () << '\n';
52
53 // output the contents of the stream objects to standard output
54 std::cout << a.str () << '\n' << b.rdbuf () << '\n';
55
56 // the dtors of a and b will not release any storage
57 // since the objects did not allocate any
58
59 // the dtor of out will release allocated storage since
60 // neither freeze() nor str() was called on the object
61
62 return 0;
63}
#define a
Definition 17.names.cpp:109
#define b
Definition 17.names.cpp:110
const int out
int main()