Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   problem in merging the files (http://www.go4expert.com/forums/merging-files-t11936/)

san.crazy 7Jul2008 23:15

problem in merging the files
 
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();
    // input directory

      printf("enter the full path of directory the content of which is to reconcile\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

san.crazy 8Jul2008 20:42

Re: problem in merging the files
 
please someone check this out


All times are GMT +5.5. The time now is 02:53.