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