Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:15:31+00:00 2026-06-05T01:15:31+00:00

I am trying to read a .gz file and print the text content on

  • 0

I am trying to read a .gz file and print the text content on screen by using boost::iostreams. This is just a simple experiment to learn about this library, and I am using the “directors.list.gz” file from IMDb (ftp://ftp.fu-berlin.de/pub/misc/movies/database/) as my input file.

My code compiles, via MSVC-10, but the process aborts when executed. There’s not much information from the error message except for the error code being R6010.

Can someone please point me a direction in terms of what may have caused this and how do I make this work?

This library looks pretty neat and I do hope to use it correctly. Thanks a lot for helping.

#include <fstream>                 // isalpha
#include <iostream>                // EOF
#include <boost/iostreams/categories.hpp> // input_filter_tag
#include <boost/iostreams/operations.hpp> // get
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/filter/zlib.hpp>


using namespace std;
namespace io = boost::iostreams;


int main() 
{

    if(true)
    {

        string infile_path = "c:\\Temp\\directors.list.gz";
        ifstream infile(infile_path, ios_base::in | ios_base::binary);
        io::filtering_streambuf<io::input> in; //filter
        in.push(io::zlib_decompressor());       
        in.push(infile); 

        //output to cout
        io::copy(in, cout);
    }

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:15:33+00:00Added an answer on June 5, 2026 at 1:15 am

    The gzip file format has an additional header around the zlib data, which zlib can’t read.

    So you want to use boost’s gzip_decompressor instead of zlib_decompressor.

    in.push(gzip_decompressor());
    

    Note you’ll need to include boost/iostreams/filter/gzip.h instead of boost/iostreams/filter/zlib.h.

    Here’s a working example of streaming a GZIP file:

    #include <fstream>
    #include <iostream>
    #include <boost/iostreams/filtering_streambuf.hpp>
    #include <boost/iostreams/filter/gzip.hpp>
    #include <boost/iostreams/copy.hpp>
    
    using namespace boost::iostreams;
    
    int main()
    {
        std::ifstream file("hello.gz", std::ios_base::in | std::ios_base::binary);
        filtering_streambuf < input > in;
        in.push(gzip_decompressor());
        in.push(file);
        boost::iostreams::copy(in, std::cout);
    }
    

    You’ll find more information on specific boost::iostreams filters lurking here in boost’s documentation: http://www.boost.org/doc/libs/1_46_1/libs/iostreams/doc/quick_reference.html#filters

    I also feel I should point out that your code didn’t compile with gcc: in the C++ standard library, the ifstream constructor takes a const char *, not a std::string. (I’m not sure about Microsoft’s version).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read all content from a text file. Here is the
I'm trying to read a text file, i'm using fileImputStream, and reading all the
I am just trying to read each character of the file and print it
I'm trying to read a text file one line at a time and print
I am trying to read the text content of a pdf file into a
I am trying to read file headers using java, I want to get file
I'm trying to read a file in my maven project at /src/main/resources/file.txt. I'm using
I'm trying to read and print a file that may or may not contain
I'm trying to read a line of text from a text file and put
I'm trying to read a file then append some text to a certain place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.