Loading
View RSS Feed

Raks' Blog

C Program To Copy a File Using Command Line Argument

Rate this Entry
C Program To Copy a File Using Command Line Argument:-

Code:
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>

void main(int argc,char *argv[])
  { 
     FILE *p,*s;
     char a;
     clrscr();
     p=fopen(argv[1],"r");
     s=fopen(argv[2],"r+");
       if (argc!=3)
         {
           printf("Wrong number of parameters given");
           exit(0);
         }
        while(!feof(p))
         {
            a=fgetc(p);
            fputc(a,s);
         }
         fclose(p);
         rewind(s);
         while(!feof(s))
          {
            a=fgetc(s);
            printf("%c",a);
          }
         getch();
        }

Submit "C Program To Copy a File Using Command Line Argument" to Digg Submit "C Program To Copy a File Using Command Line Argument" to del.icio.us Submit "C Program To Copy a File Using Command Line Argument" to StumbleUpon Submit "C Program To Copy a File Using Command Line Argument" to Google

Comments




Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.