hi friends,
I've coded a file merging program in C. though, the program seems to work far upto as how it supposed to but there is a problem.
when i tried to merge few media files to make it a whole in one then i got its size desirable equal to the sum of all ones though but I didn't get it played anyway.
Code:
#include<stdio.h>
#include<string.h>
char buffer[BUFSIZ];
main()
{
FILE *fsource,*fdest; char dirpath[30],sourcepath[40],destpath[40];
int files=0,count;
clrscr();
printf("enter the full path of directory the content of which is to merge\n");
gets(dirpath);
printf("\nenter the number of files stored in this directory");
scanf("\n%d",&files);
strcpy(destpath,dirpath);
strncat(destpath,"movie.flv",9);
fdest=fopen(destpath,"wb+");
setvbuf(fdest,buffer,_IOFBF,BUFSIZ);
fseek(fdest,0L,1);
for(count=1;count<=files;count++)
{
sprintf(sourcepath,"%s%d%s",dirpath,count,".flv");
fsource=fopen(sourcepath,"rb+");
fseek(fsource,0L,1);
setvbuf(fsource,buffer,_IOFBF,BUFSIZ);
printf("\npart %d is being processed",count);
while(fread(buffer,BUFSIZ,1,fsource))
{
fseek(fsource,BUFSIZ,1);
fwrite(buffer,BUFSIZ,1,fdest) ;
fseek(fdest,BUFSIZ,1);
}
printf("\npart %d is processed",count);
}
}
please someone nail out the problem