You are here:

C/How read text file inside Archive files by 'C '


I have tried finding the solution for the problem on google but unable to find a solution that supports both the Archive formats i.e Rar/Zip.I tried with 7zip [7zip][1] but it has functions thar compress/decompress or extracts the contents of Archive files , While searching for the solution I found minizip supports both the formats Rar/Zip with [minizip][2]

I tried to open the text file inside Archive,but it's unable to open it.

Possibly I am looking forward to  [zlib][3] as a possible approach but it is a dll,and I dont know about how its functions work and do they perform the task of reading from a text file inside the Archive.

So, please give guidance as how to move ahead in this task, i am not sure with zlib.

**Making the requirement clear again**

I just want to read the content of text files inside archive (rar/zip) For e.g I have Archive C:\Test.rar and Test.rar contains filesample.txt , so my requirement is to read the content of filesample.txt directly ,I dont want to extract the files.


Hi Dhawal,

Based on your requirements libarchive looks like a good choice. libarchive is an opensource library that supports both rar and zip. The libarchive github page has good documentation with examples:



All Answers

Answers by Expert:

Ask Experts


Tony Nazzal


I will answer any c language programming and syntax questions.


I have almost a decade of c programming experience.

I have a bachelor of science degree and several years of industry experience.

©2016 All rights reserved.