Source code for file copy command
/ * Name: x_copy.c author: x-bit at 167168.kmip.net (Pure Technology Forum) Description: File Copy Command, you can only copy a file. Usage: Command Source file target file DEV-CPP5 WIN2K Under debugging; reproduced please keep your article integrity. Date: 08-11-2004 Copyright: X-bit (Si brother) allrights reserved. * /
#include void usage (char * msg) {PUTS (MSG); "Usage: command source target"); exit (0);} void errmsg (char * msg) {PUTS ("File Operation Failure. "); PUTS (MSG); EXIT (0);} int main (int Argc, char * argv []) {file * si, * di; if (argc == 1) {usage (" parameter error " Else IF (ARGC == 2) {IF (Si = FOPEN (ARGV [1], "RB")) USAGE ("Unable Copy To Itself./ncopy 0 file."); Else USAGE ("Can ' } else if (argc> 3) {usage ("parameter error");} if (! (si = fopen (argv [1], "rb"))))) Errmsg ("can't Open the file "); if (! (DI = FOPEN (Argv [2]," WB "))))) Errmsg (" can't create the file "); while (! Feof (si)) FPUTC (Fgetc (Si ), Di); Fclose (Si); Fclose (DI); PUTS ("Copyed 1 File."); return 0;}