ejercicio de argchivos
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
ESTE ES UN ARCHIVO
|
||||
DE PRUEBAS DONDE VAMOS A EVALUAR COMO
|
||||
SE COPIA ESTE CORREO HORACIODRS@GMAIL.COM
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *src = "src-test.txt";
|
||||
char *dst = "dst-test.txt";
|
||||
|
||||
if (argc == 3) {
|
||||
src = strdup(argv[1]);
|
||||
dst = strdup(argv[2]);
|
||||
} else {
|
||||
fprintf(stderr, "Argumentos invalidos.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *fpsrc, *fpdst;
|
||||
|
||||
fpsrc = fopen(src, "r");
|
||||
|
||||
if (fpsrc == NULL) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fpdst = fopen(dst, "w");
|
||||
|
||||
if (fpdst == NULL) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int c;
|
||||
while ((c = fgetc(fpsrc)) && c != EOF) {
|
||||
fputc(toupper(c), fpdst);
|
||||
}
|
||||
|
||||
fclose(fpsrc);
|
||||
fclose(fpdst);
|
||||
|
||||
printf("Archivo duplicado en mayusculas con exito en: %s\n", dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Este es un archivo
|
||||
de pruebas donde vamos a evaluar como
|
||||
se copia este correo horaciodrs@gmail.com
|
||||
Reference in New Issue
Block a user