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