Blog Archive

Sunday, August 29, 2010

Program for coping text files using command line argument.

/*
Program for coping text files using command line argument.
*/

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main1(int argc, char *argv[])
{
char *nm1,*nm2;
nm1=argv[1];
nm2=argv[2];
FILE *fp1,*fp2;
fp1 = fopen(nm1,"r");
fp2 = fopen(nm2,"w");
while(!feof(fp1))
{
char ch;
ch= fgetc(fp1);
fputc(ch,fp2);
}
fclose(fp1);
fclose(fp2);
printf("File Copied Successfully.");
return 0;
}

No comments:

Post a Comment