2dix-The Student Choice
Log in Register now

Write a Program of CONCATENATE MANY FILES AND STORE THEM IN A FILE NAMED FILES. [Use command line arguments to pass the file names]

Write a Program of CONCATENATE MANY FILES AND STORE THEM IN A FILE NAMED FILES.
[Use command line arguments to pass the file names]


#include<stdio.h>

void concatenate(FILE *fp1,FILE *fp2,char *argv[],int argc);
void main(int argc,char *argv[])
{
FILE *fp1,*fp2;
concatenate(fp1,fp2,argv,argc);
getch();
}
void concatenate(FILE *fp1,FILE *fp2,char **argv,int argc)
{
int i,ch;
fp2=fopen("files","a");
for(i=1;i<argc-1;i++)
{
fp1=fopen(argv[i],"r");
while((ch=getc(fp1))!=EOF)
putc(ch,fp2);
}
}


comments (1)

avatar
1
[url
avatar