002
15.06.2003, 13:47 Uhr
~0xdeadbeef
Gast
|
Ich würd sowas machen:
C++: |
int fcopy(const char *from_name, const char *to_name) { FILE *from, *to; char buf[1024]; /* wir schreiben Kilobyteweise */ int len;
if((from = fopen(from_name, "r")) == NULL) return -1; if((to = fopen(to_name, "w")) == NULL) { fclose(from); return -1; }
while(!feof(from)) { len = fread(buf, sizeof(char), 1024, from); if((len <= 0 && !feof(from)) || fwrite(buf, sizeof(char), len, to) <= 0) { /* Fehler */ fclose(from); fclose(to); return -1; } }
fclose(from); fclose(to);
return 0; }
|
|