Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active November 1, 2018 09:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thinkphp/934ea418bcfa965146a84a7cd64ebdb0 to your computer and use it in GitHub Desktop.
mv filename1 filename2
#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