I know only basic file handling and was wondering if anyone would help me out with the following code :
1. Extract an archive using C
2. Extract an archive with password using C
I know only basic file handling and was wondering if anyone would help me out with the following code :
1. Extract an archive using C
2. Extract an archive with password using C
Welcome to the forum!
To get help, you need to show your work on the problem. Our help is rather limited to C, not decrypting an encoded archive or cracking a password.
I'm not saying you're trying to do that, I'm just being up front about this.
We help folks with C, all the time.
Well, i'm new to C and i know the basic file-handling functions like fopen, fprintf etc.
I have implemented these functions only in text files and database programs using
fptr1=fopen("data.txt","r+");
if(fptr1==NULL)
{
printf("ERROR");
exit(1);
}
fprintf(fptr1,"Record No.\tName\t\tRoll No.\tAggregate Marks");
......... and so on
i was wondering if a program could be written in C to extract an archive(Zip,RAR)
And you've misunderstood me on the second count .. i meant that i would have the password and i would just be extracting a file using c instead of manually, so i think that eliminates the decrypting part.
Simply put ... all i want to do is extract an archive of which i already have the password ...using C, assuming of course that the archive is in the same folder as the executable file after compilation
Last edited by cerebrassassin; 10-25-2009 at 08:57 PM.
Oh yes, of course you can extract zip and rar files with C . In all likelihood, both were written in C in the first place.
However, the easier way to do this, is to use a de-compression program that runs from the command line, and handles the format you want (whether zip or rar or both).
Now your C program can just use the system command to call that program, let it do it's work, and then return to work, having just paused, while the de-compression program was working.
Imagine I have a program called "unzip.exe", which was a command line program (no gui needed), and took two parameters:
1) the name of the file, and
2) the password needed, if any.
Now my C code for it could look something like this:
system("unzip filename password");
filename doens't have to be a single filename, it can change, and so can the password, by changing the above command slightly:
system("QuestSolver.exe < "filename) //note the string quotes ending before filename
In this case, I was calling another program called Questsolver.exe and giving it the file I had #defined earlier, which was in another drive and directory.
I believe you can call send any filename like this, using a char array for filename, but haven't tried it yet.
Where it gets sticky is when the program has to run from a GUI, and you have to click on certain icons, or check certain boxes - all that mouse and keyboard interaction is what you want to avoid.
I'd put off coding up the actual de-compression program yourself, until you have quite a bit of experience with C programming and of course, have a good understanding of the algorithm that should be used.
Thanx a ton dude....
I got hold of this freeware called 'UNRAR' and as you advised, I used the system's command prompt to extract the files and it works like a charm.
Thnx again ... this forum rox... i'm here to stay!!!