|
|
Mensaje: #1
Copiar archivo
Una forma un poco tosca de copiar un archivo en C/C++.
Se parece mucho a la función sCopyFile realizada anteriormente en Python:
Lenguaje C++
void sCopyFile(char *sFrom, char *sTo)
{
FILE *sFile, *sNewFile;
char *Buffer = NULL;
int i = 0;
sFile = fopen(sFrom,"rb");
sNewFile = fopen(sTo,"wb");
while (fgetc(sFile) != EOF)
{
i++;
}
rewind(sFile);
Buffer = (char*) malloc(i * sizeof(char));
fread(Buffer,1,i,sFile);
fwrite(Buffer,1,i,sNewFile);
fclose(sFile);
fclose(sNewFile);
free(Buffer);
}
"The only thing they can't take from us are our minds."
|
|
| 30-12-2010 09:38 AM |
|