-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArchivoLeerYCopiar.c
47 lines (43 loc) · 979 Bytes
/
ArchivoLeerYCopiar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Leer y copiar Archivos verificando si está el archivo
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int main()
{
FILE * entr, *sal;
int car, opc;
entr = fopen("Origen.txt", "rt");
if (entr==NULL)
{
printf("No se encontró arch. de entrada\n");
return 1;
}
else
{
sal =fopen ("Destino.txt", "rt");
if (sal != NULL)
{
printf("Desea sobreescribirlo? ");
opc = fgetc(stdin);
fgetc(stdin);
if (toupper(opc)!='S')
{
printf("No se sobrescribe\n");
fclose(entr);
fclose(sal);
return 1;
}
else
fclose(sal);
}
car = fgetc(entr);
while (!feof(entr))
{
fprintf(sal, "%c", (char)car);
car = fgetc(entr);
}
fclose(entr);
fclose(sal);
}
return 0;
}