// PROGRAMA QUE UNE VARIOS FICHEROS EN UNO SOLO ANTERIORMENTE PARTIDO // NOMBREFICHERO.1 NOMBREFICHERO.2 --> NOMBREFICHERO #include #include #define TAM 1024 int main (int argc, char *argv[]) { FILE *fent, *fsal; char bloque[TAM]; char ficherobloque[100]; int nbytes, I; if (argc != 2) { puts ("Error en parametros"); exit (1); } fsal = fopen (argv[1], "wb"); if (fsal == NULL) { printf ("Error al abrir %s \n", argv[1]); exit (2); } I=1; sprintf(ficherobloque,"%s.%d",argv[1],I); fent = fopen (ficherobloque, "rb"); while(fent != NULL) { nbytes =fread (bloque,1,TAM,fent); fwrite (bloque,1,nbytes,fsal); fclose(fent); I++; sprintf (ficherobloque, "%s.%d", argv[1],I); fent = fopen (ficherobloque, "rb"); } fclose(fsal); printf("\n Unión realizada de %d trozos.\n",I-1); }