C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-25-2009, 07:18 PM   #1
Registered User
 
Join Date: Oct 2009
Posts: 6
Extracting archive

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
cerebrassassin is offline   Reply With Quote
Old 10-25-2009, 08:16 PM   #2
Registered User
 
Join Date: Sep 2006
Posts: 3,720
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.
Adak is offline   Reply With Quote
Old 10-25-2009, 08:41 PM   #3
Registered User
 
Join Date: Oct 2009
Posts: 6
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.
cerebrassassin is offline   Reply With Quote
Old 10-25-2009, 09:59 PM   #4
Registered User
 
Join Date: Sep 2006
Posts: 3,720
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.
Adak is offline   Reply With Quote
Old 10-26-2009, 02:52 AM   #5
Registered User
 
Join Date: Oct 2009
Posts: 6
Cool

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!!!
cerebrassassin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting info from a packet trace file Ho ming C Programming 1 03-31-2008 11:54 AM
C++ snippet Archive squako C++ Programming 16 12-17-2006 12:12 PM
Testers wanted - archiving tool. ahluka Game Programming 25 08-31-2006 06:12 AM
archive format Nor A Brief History of Cprogramming.com 0 08-05-2003 07:01 PM
extracting words from an array of words axon C++ Programming 2 04-02-2003 11:21 PM


All times are GMT -6. The time now is 12:03 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22