I use Linux system with GNU gcc compiler.
I have written the following code for copying string of one file to another.
-this code mainly take two file names as input and copies from one to another.
> the program is compiled and has no errors but the problem is that when I first give input in the terminal like
Its saying no command exists....
filecopy file1.txt file2.txt
the same I used in windows dos and it worked.
what kind of command should I use while giving input ?
# include <stdio.h>
# include <stdlib.h>
int main ( int argc, char *argv )
FILE *psCopy, *psPaste ;
char ch ;
if ( argc != 3 )
printf("Insufficient number of arguments\n");
psCopy = fopen ( argv , "r" );
if ( !psCopy )
printf ("File couldn't open. Sorry!\n");
psPaste = fopen ( argv , "w" );
if ( !psPaste )
printf ("File couldn't open. \n");
while ( (fscanf (psCopy,"%c",&ch)) == 1 )
fprintf (psPaste,"%c",ch) ;
fclose (psCopy) ;
fclose (psPaste) ;