Last active
August 29, 2015 13:57
-
-
Save yuikns/9807331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void file_copy(const char * dest, const char* src) | |
{ | |
FILE * fsrc = fopen(src,"rb"); | |
FILE * fdest = fopen(dest,"wb"); | |
fseek(fsrc,0L,SEEK_END); | |
long sz = ftell(fsrc); | |
rewind(fsrc); | |
unsigned char * buff = (unsigned char *)malloc(sizeof(unsigned char) * sz); | |
fread(buff,sz,sizeof(unsigned char),fsrc); | |
fwrite(buff,sz,sizeof(unsigned char),fdest); | |
free(buff); | |
fclose(fsrc); | |
fclose(fdest); | |
} | |
void file_copy2(const char * dest, const char* src) | |
{ | |
FILE * fsrc = fopen(src,"rb"); | |
FILE * fdest = fopen(dest,"wb"); | |
rewind(fsrc); | |
unsigned char buff[1024]; | |
size_t sz; | |
while((sz = fread(buff,1,1024,fsrc)) > 0 ) | |
{ | |
fwrite(buff,1,sz,fdest); | |
} | |
fclose(fsrc); | |
fclose(fdest); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment