i have creaed a loop that lets the user creates a file then copy a file to it and also allows the user to add more than 1 file to be copied. the problem that i found out is that when the progam goes back round the loop it drops what ever is in the pointer and only copies the recent selection. is there a solution to this ?
for example
while (1)
{
printf("please type in the path for the file you want to archive\n");
scanf("%s",&original_file);
open_pointer = fopen( original_file, "r+b");
original_pointer = fopen(original_file,"a+b");
copy_pointer = fopen( archive_name,"wa+b");
if (copy_pointer != NULL)
{
printf("\n enter any charachter appart from x to add other files to be copied");
puts("\n or enter x to coninue");
scanf("%s",&answer);
if(answer != 'x')
continue;
}
else
{
if( answer == 'x')
break;
}
while ((n = fread(buffer,1,sizeof buffer, original_pointer)) > 0)
{
fwrite(buffer,1, n , copy_pointer); //fwrite only writes what is curently in the pointer