Search C Program | nimishsoft@gmail.com

File Copy using command line arguments

/* File Copy using command line arguments */

#include<stdio.h>
int main(int argc,char *argv[])
{
 FILE *fs,*ft;
 int ch;
 if(argc!=3)
 {
  printf("Invalide numbers of arguments.");
  return 1;
 }
 fs=fopen(argv[1],"r");
 if(fs==NULL)
 {
  printf("Can't find the source file.");
  return 1;
 }
 ft=fopen(argv[2],"w");
 if(ft==NULL)
 {
  printf("Can't open target file.");
  fclose(fs);
  return 1;
 }

 while(1)
 {
  ch=fgetc(fs);
  if (feof(fs)) break;
  fputc(ch,ft);
 }

 fclose(fs);
 fclose(ft);
 return 0;
}


18 comments:

  1. Replies
    1. Invalide numbers of argument

      Delete
    2. Attention everyone, the file provided above is not working. I have been looking for the working file and finally found it.



      ✔️Click Here To Download http://gestyy.com/e0GAyS
      ✔️Click Here To Download

      ✔️Click Here To Download http://exe.io/XONVsO6l

      ✔️Click Here To Download


      ✔️Click Here To Download
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .

      .

      .
      .

      .

      .
      .
      .
      .

      Mn.
      ..

      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .zxzxzx
      .sdcccxxx

      Delete
    3. step 1. put the code in file name " example.c"
      step 2. compile the code file " example.c "
      step 3. after compiling the code you get the " example.exe "
      step 4. open turboc++ shell and find the location of the "example.exe or example.c"
      step 5. make two txt file in one.txt file put same line of statements in my case i put the random statement "xyz"
      step 6. after this above steps then put this command in turbox++ shell example.exe one.txt second.txt
      step 7. now open the second.txt file your got the
      "xyz"

      Delete
  2. Plz can u explain me y u used a while(1).................i mean wat exactly is the condition over there?

    ReplyDelete
    Replies
    1. while(1) is used there for infinite loop. if eof is found then we are exiting loop here...

      Delete
    2. feof means end of file..
      when file ended break executes

      Delete
  3. pls tell me the output

    ReplyDelete
  4. I am interested to buy your website if please contact for sell this is my website link here visit and click on contact or servers page you got my mobile number Features of C

    ReplyDelete