I have a c++ program which has some command line options. One of them is the file name. The file size is big so I decided to compress it and then try to find a way that the c++ program read the compressed file instead of the plain text file.
According to what is stated here How to read a .gz file line-by-line in C++? I tried the second answer but it doesn't work.
Assume the normal command line for running my program is
./run 1 file.txt 10
Now I run
zcat file.gz | ./run 1 file.gz 10
But the output is invalid. How can I fix that?
P.S:
The file looks like
10 1000
2 39
45 124
And the code which reads the file looks like
char *inp = argv[2];
std::ifstream fin (inp);
int a, b;
while (fin >> a >> b ) {
// somthing
}