I want to extract a .rar file to a folder using c++ with zlib.
My Code:
int main (){
gzFile infile = gzopen("C:\\Users\\Nico\\Desktop\\a.rar", "rb");
FILE *outfile = fopen("C:\\Users\\Nico\\Desktop\\ToThisFolder", "wb");
if (!infile || !outfile) {
return -1;
}
char buffer[128];
int num_read = 0;
while ((num_read = gzread(infile, buffer, sizeof(buffer))) > 0) {
fwrite(buffer, 1, num_read, outfile);
}
gzclose(infile);
fclose(outfile);
}
If I run the code, my program always go to return -1, because he don't accept the output file.
If you look to my outfile, i want to put the output into a folder.
How can I do this?
ThecCode is from http://www.codeguru.com/cpp/cpp/algorithms/compression/article.php/c11735/zlib-Add-Industrial-Strength-Compression-to-Your-CC-Apps.htm
Thanks