Advertisement
Kl43z

Copiar un archivo a otro

Nov 27th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main(){
  5.     FILE *f1,*f2,*f3;
  6.     int i;
  7.     f1=fopen("archivo1.txt","r");
  8.     f2=fopen("archivo2.txt","w");
  9.     f3=fopen("archivo3.txt","w");
  10.     printf ("\nSeleccione a cual archivo copiar: \n\n");
  11.     printf ("1)Archivo2.txt\n");
  12.     printf ("2)Archivo3.txt\n>> ");
  13.     scanf ("%d", &i);
  14.     switch (i){
  15.         case 1:
  16.             do{
  17.                 fprintf(f2,"%c", getc(f1));
  18.        
  19.             }while(!feof(f1));
  20.             break;
  21.         case 2:
  22.             do{
  23.                 fprintf(f3,"%c", getc(f1));
  24.        
  25.             }while(!feof(f1));
  26.             break;
  27.         default:
  28.             printf ("Opcion no valida\n");
  29.             return 0;
  30.  
  31.     }
  32.     fclose(f1);
  33.     fclose(f2);
  34.     fclose(f3);
  35.    
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement