xref: /netbsd-src/external/gpl3/gdb/dist/zlib/contrib/iostream2/zstream_test.cpp (revision 212397c69a103ae7e5eafa8731ddfae671d2dee7)
1*212397c6Schristos #include "zstream.h"
2*212397c6Schristos #include <math.h>
3*212397c6Schristos #include <stdlib.h>
4*212397c6Schristos #include <iomanip.h>
5*212397c6Schristos 
main()6*212397c6Schristos void main() {
7*212397c6Schristos     char h[256] = "Hello";
8*212397c6Schristos     char* g = "Goodbye";
9*212397c6Schristos     ozstream out("temp.gz");
10*212397c6Schristos     out < "This works well" < h < g;
11*212397c6Schristos     out.close();
12*212397c6Schristos 
13*212397c6Schristos     izstream in("temp.gz"); // read it back
14*212397c6Schristos     char *x = read_string(in), *y = new char[256], z[256];
15*212397c6Schristos     in > y > z;
16*212397c6Schristos     in.close();
17*212397c6Schristos     cout << x << endl << y << endl << z << endl;
18*212397c6Schristos 
19*212397c6Schristos     out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results
20*212397c6Schristos     out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl;
21*212397c6Schristos     out << z << endl << y << endl << x << endl;
22*212397c6Schristos     out << 1.1234567890123456789 << endl;
23*212397c6Schristos 
24*212397c6Schristos     delete[] x; delete[] y;
25*212397c6Schristos }
26