Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define MAX 40
  4.  
  5. void main()
  6. {
  7. FILE * fichero1, * fichero2;
  8. char nombre[MAX];
  9. char datos;
  10.  
  11. printf("Introduzca el nombre del fichero: ");
  12. scanf("%s", nombre);
  13.  
  14. fichero1 = fopen (nombre, "r");
  15.  
  16. if (fichero1 == NULL)
  17. {
  18. printf ("Error abriendo %s\n", nombre);
  19. return;
  20. }
  21.  
  22. printf ("Introduzca el nombre del fichero2: ");
  23. scanf ("%s", nombre);
  24. fichero2 = fopen (nombre, "w");
  25.  
  26. if (fichero2 == NULL)
  27. {
  28. printf ("Error abriendo %s\n", nombre);
  29. return;
  30. }
  31.  
  32. while(!feof(fichero1))
  33. {
  34. fscanf(fichero1,"%c", &datos);
  35. fprintf(fichero2,"%c", datos);
  36. }
  37.  
  38. fclose(fichero1);
  39. fclose(fichero2);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement