Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX 40
- void main()
- {
- FILE * fichero1, * fichero2;
- char nombre[MAX];
- char datos;
- printf("Introduzca el nombre del fichero: ");
- scanf("%s", nombre);
- fichero1 = fopen (nombre, "r");
- if (fichero1 == NULL)
- {
- printf ("Error abriendo %s\n", nombre);
- return;
- }
- printf ("Introduzca el nombre del fichero2: ");
- scanf ("%s", nombre);
- fichero2 = fopen (nombre, "w");
- if (fichero2 == NULL)
- {
- printf ("Error abriendo %s\n", nombre);
- return;
- }
- while(!feof(fichero1))
- {
- fscanf(fichero1,"%c", &datos);
- fprintf(fichero2,"%c", datos);
- }
- fclose(fichero1);
- fclose(fichero2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement