c语言 13 - 8
1、
#include <stdio.h> int main(void) { int ch; FILE *sfp; FILE *dfp; char sfile[FILENAME_MAX]; char dfile[FILENAME_MAX]; printf("sfile name: "); scanf("%s", sfile); printf("dfile name: "); scanf("%s", dfile); if((sfp = fopen(sfile, "r")) == NULL) printf("\aSource file open failed.\n"); else { if((dfp = fopen(dfile, "w")) == NULL) printf("\aDestination file open failed.\n"); else { while((ch = fgetc(sfp)) != EOF) { putchar(ch); fputc(ch, dfp); } fclose(dfp); } fclose(sfp); } return 0; }