- 205 名前:デフォルトの名無しさん mailto:sage [2008/06/11(水) 00:59:04 ]
- >>165
#include<stdio.h> #include<stdlib.h> #define SRC_FILE "test.txt" #define DST_FILE "sample.txt" int main() { FILE *fs, *fd; long size, i; char *buf; if((fs = fopen(SRC_FILE, "r")) == NULL) { perror(SRC_FILE); return 1; } if((fd = fopen(DST_FILE, "w")) == NULL) { fclose(fs); perror(DST_FILE); return 1; } fseek(fs, 0, SEEK_END); size = ftell(fs); fseek(fs, 0, SEEK_SET); buf = malloc(size); size = fread(buf, 1, size, fs); for(i = size - 1; i >= 0; i --) fputc(buf[i], fd); free(buf); fclose(fd); fclose(fs); return 0; }
|

|