10:58 AM
C++ Program for 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);
}
}
Views: 111 | Added by: vijoriya | Tags: files, store, c++, program, CONCATENATE | Rating: 0.0/0
Total comments: 0
avatar