/* * Code example for CP264 Data Structures II * File copy * HBF */ #include #include int main() { char ch, file1[20], file2[20]; FILE *fs,*ft; printf("Enter source file name:"); gets(file1); fs = fopen(file1,"r"); if( fs == NULL ) { perror("Error"); return 0; } printf("Enter destination file name:"); gets(file2); ft = fopen(file2,"w"); if( ft == NULL ) { perror("Error"); fclose(fs); return 0; } while( ( ch = fgetc(fs) ) != EOF ) { fputc(ch, ft); } printf("File copied successfully.\n"); fclose(fs); fclose(ft); return 0; }