I am acquainted that some folks have already written about this question; however, this question is not clear to me yet. I need to read gzipped files which contain unformatted data. I have unsuccessfully tried following instructions from zlib and gzstream sites. Could anybody provide me a quick example of how to extract data directly from the compressed gzip file using an ifstream? My procedure using dat files is the following:
#include <iostream>
#include <sstream>
#include <string>
int main () {
ifstream file;
string stringtemp;
stringstream line2convert;
file.open("directory/file.dat");
// read each line using a for loop (I know the total number of lines)
file.getline (line,100);
// extract information line by line using stringstreams
line2convert << line;
line2convert >> int2convert;
...
...
...
}
Anybody could give me a hint to add a few lines that I need?
Thanks!
– F
if you know how to link in gzstream, you can do that
just replace “ifstream” with “igzstream”
.