I want to compress a intermediate output of my program ( in C++) and then decompress it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can use Boost IOStreams to compress your data, for example something along these lines to compress/decompresses into/from a file (example adapted from Boost docs):
You can also have a look at Boost Serialization – which can make saving your data much easier. It is possible to combine the two approaches (example). IOStreams support
bzipcompression as well.EDIT: To address your last comment – you can compress an existing file… but it would be better to write it as compressed to begin with. If you really want, you could tweak the following code: