Mercurial > hg > sv-dependency-builds
annotate src/zlib-1.2.7/contrib/iostream2/zstream_test.cpp @ 169:223a55898ab9 tip default
Add null config files
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Mon, 02 Mar 2020 14:03:47 +0000 |
parents | 8a15ff55d9af |
children |
rev | line source |
---|---|
cannam@89 | 1 #include "zstream.h" |
cannam@89 | 2 #include <math.h> |
cannam@89 | 3 #include <stdlib.h> |
cannam@89 | 4 #include <iomanip.h> |
cannam@89 | 5 |
cannam@89 | 6 void main() { |
cannam@89 | 7 char h[256] = "Hello"; |
cannam@89 | 8 char* g = "Goodbye"; |
cannam@89 | 9 ozstream out("temp.gz"); |
cannam@89 | 10 out < "This works well" < h < g; |
cannam@89 | 11 out.close(); |
cannam@89 | 12 |
cannam@89 | 13 izstream in("temp.gz"); // read it back |
cannam@89 | 14 char *x = read_string(in), *y = new char[256], z[256]; |
cannam@89 | 15 in > y > z; |
cannam@89 | 16 in.close(); |
cannam@89 | 17 cout << x << endl << y << endl << z << endl; |
cannam@89 | 18 |
cannam@89 | 19 out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results |
cannam@89 | 20 out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; |
cannam@89 | 21 out << z << endl << y << endl << x << endl; |
cannam@89 | 22 out << 1.1234567890123456789 << endl; |
cannam@89 | 23 |
cannam@89 | 24 delete[] x; delete[] y; |
cannam@89 | 25 } |