Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void fileCopy(char *source, char *destination);
- int main()
- {
- char sourceFile[] = "input.txt";
- char destinationFile[] = "output.txt";
- fileCopy(sourceFile, destinationFile);
- return 0;
- }
- void fileCopy(char *source, char *destination)
- {
- FILE *fp1, *fp2;
- int ch;
- fp1 = fopen(source, "r");
- fp2 = fopen(destination, "w");
- if(fp1 == NULL || fp2 == NULL)
- {
- printf("Error opening file.\n");
- exit(1);
- }
- while(1)
- {
- ch = fgetc(fp1);
- if(ch == EOF) break;
- else fputc(ch, fp2);
- }
- fclose(fp1);
- fclose(fp2);
- remove(source);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement