How to create a archive file in c language?


Hi friends,
I wanted to create a archive file in c language.(in Windows)
If you know any predefined function to create archive file plz tell me.
OR
If you know any dos command to create archive(zip/rar) plz help me.

2 Responses to “How to create a archive file in c language?”

  • jplatt39:

    There are so many free programs for creating zip files (the algorithm is well known and the relevant IP registrations having for the most part expired,) it doesn’t seem worth it to reinvent the wheel. Here is a free zip program for Windows:

    http://www.trans4mind.com/personal_development/zipper/

    7-zip, which is cited above, is an excellent program. It is also Open Source which means you can get the source code here:

    http://www.7-zip.org/sdk.html

    Linux has zip and unzip programs which, being Linux, have source code available as well. Look for the zlib library.

    However, part of the c standard is a function in stdlib called system() as in system(char *commandstring); Now commandstring is an ASCIIZ string (A 0 delimited array of char) which sends the operating system a command such as "unzip <myfile>". If you know what file you want to unzip, no problem. If you don’t, you can use the stdio function sprintf at runtime, as in sprintf(*commandstring, "zip %s", <myfile>); to construct your command line once you know what the name of myfile is. You don’t need to reinvent the wheel unless you want to.

  • l815s:

    I’m not really sure of an exact solution, but I do know you can do this via command line with a utility called 7zip.

Leave a Reply