Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- char infile[40], outfile[40];
- FILE *fin, *fout ;
- int c;
- printf("Source file: ");
- scanf("%39s", infile);
- printf("Copy file: ");
- scanf("%39s", outfile);
- if ((fin=fopen(infile, "r")) == NULL) {
- fprintf(stderr, "Source file open error.\n");
- return 1;
- }
- if ((fout=fopen(outfile, "w")) == NULL) {
- fprintf(stderr, "Copy file open error.\n");
- fclose(fin);
- return 1;
- }
- while ((c=fgetc(fin))!=EOF) {
- fputc(c, fout);
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement