I need to write a simple archiving program in C. It must be able to read in one or more files and output them in a single file. I must then be able to extract the files to the same directory as they were in before. I am able to read files using 'read' and 'fread' and also write files, but i can only do these things with one file at a time.
Any help would be greatly appreciated
Have you checked out zlib? zlib Home Site
Perhaps you need help with reading the command line
Cprogramming.com FAQ > Accessing command line parameters/arguments
So you can do say
myprog myarchive file1 file2 file3
First off, you should give this your best shot on your own... Get it as far as you can then when you get stuck post up your code and we'll see what we can accomplish....
Originally Posted by smoothjammy1
Basically an archive is just a big file that, in this case, contains the contents of other files. To do this you will need to design a header system, essentially a linked list just like in memory except using the file position instead of memory pointers as your linking reference. The headers can be a simple struct... previous header, file path, file size, next header. In the archive file itself you write a header, the file contents, the next header, file contents, header, contents etc. From there it's just like adding, reading, etc. with a linked list.
C Archiving help
Thanks for the speedy reply, will give it my best shot...