so far the user can select a file that he want to open to be copied, is there a way of letting the user selecting multiple files to be copied to one file? i was thinking of looping around asking the user to add another file if the user wanted to and that would take ages if the user had a lot of files

printf("please give your archive a name and a path:\n");
scanf("%s", &archive_name);
create_pointer = fopen( archive_name, "wb");	

printf("please type in the path for the file you want to archive\n");	

scanf("%s",&original_file);

open_pointer=fopen(original_file,"rb");

original_pointer=fopen(original_file,"rb");						

copy_pointer = fopen( archive_name,"wb");

is there way of letting the user selecting multiple files ?

If you're accepting file names from stdin, a loop is pretty much the only option. You can streamline the process a little by giving users the option of simply typing all of the files at once:

printf("Files to archive: ");
fflush(stdout);

while (scanf("%s", filename) == 1)
    archive(archive_name, filename);

As long as there's no embedded whitespace in the path, you're solid. If embedded whitespace can be expected, scanf isn't suitable. You'd probably want to mimic the command shell's quoting rules, or possibly require the user to provide a manifest file which contains all of the paths to be archived (one on each line). Then fgets can be used instead of scanf.

i looked at the code its not what i wanted really but thanks it will be usefull later on.

narue i tried putting the code to work, i just dont understand this part

archive(arhive_name,filename)

i just get this error

(.text+0x6c): undefined reference to `archive'

>i just get this error
>(.text+0x6c): undefined reference to `archive'

Use your brain. The archive function in my example is a placeholder for the code you're using to copy files. I'm not going to write this all for you.

This article has been dead for over six months. Start a new discussion instead.