Write a ‘C’ program to copy content of one file into another file using command line argument

#include<stdio.h>
#include<conio.h>
main(int argc,char *argv[])
{
FILE *fp1,*fp2;
char ch;
clrscr();
if(argc!=3)
{
printf("\n insufficient argument ");
exit(0);
}
fp1=fopen(argv[1],"r");
fp2=fopen(argv[2],"w");
if(fp1==NULL || fp2==NULL)
{
printf("\n unable to open file ");
exit(0);
}
while(!feof(fp1))
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
printf("\n file successfully copied ");
fclose(fp1);
fclose(fp2);
getch();
}


Comments

  1. Write a C program that reads the file name and text of 20 words as command line arguments. Write the text into a file whose name is given as the file name.

    ReplyDelete
  2. please visit my blog arungirivasan.blogspot.in and comment your opinion.it is also about c programs

    ReplyDelete
  3. Write a program using command line parameters to append one text file to another text file.

    ReplyDelete
  4. It's showing declaration terminated incorrectly

    ReplyDelete
  5. Write a program to print the records in reverse order. The file must be opened in binary modw

    ReplyDelete
  6. This is a subject which is important to me... Good health! Where are your contact subtleties however?
    live

    ReplyDelete

  7. This blog is very infomative thanks for providing us this blog
    Oracle Training in Noida

    ReplyDelete

Post a Comment