Last active
November 1, 2018 09:18
-
-
Save thinkphp/934ea418bcfa965146a84a7cd64ebdb0 to your computer and use it in GitHub Desktop.
mv filename1 filename2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <malloc.h> | |
int main(int argc, int **argv) { | |
char ch; | |
FILE *source, *target; | |
char source_file[40], target_file[40]; | |
char *p; | |
if(argv[1] == NULL || argv[2] == NULL) { | |
printf("Argv[1] and Argv[2] are missing!"); | |
exit(EXIT_FAILURE); | |
} | |
strcpy(source_file, argv[1]); | |
source = fopen(argv[1], "r"); | |
if(source == NULL) { | |
printf("Press ny key to exit"); | |
exit(EXIT_FAILURE); | |
} | |
strcpy(target_file, argv[2]); | |
target = fopen(target_file, "w"); | |
while((ch = fgetc(source)) != EOF) fputc(ch, target); | |
printf("\nFile compied successfully!\n"); | |
fclose(source); | |
fclose(target); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment