#include<stdio.h>
void main(int argc , char *argv[])
{
FILE *file1,*file2;
char line[100];
int i=0;
for(i=1;i<argc-2;i++)
{
// initialising the file pointer to read and write
file1 = fopen(argv[i] , "r");
file2 = fopen(argv[++i],"w");
// read file1 line by line and write to next file2
while(fscanf(file1 , "%[^\n]\n" , line)!=EOF)
{
fprintf(file2 , "%s\n" , line);
}
fclose(file1);
fclose(file2);
}
}
void main(int argc , char *argv[])
{
FILE *file1,*file2;
char line[100];
int i=0;
for(i=1;i<argc-2;i++)
{
// initialising the file pointer to read and write
file1 = fopen(argv[i] , "r");
file2 = fopen(argv[++i],"w");
// read file1 line by line and write to next file2
while(fscanf(file1 , "%[^\n]\n" , line)!=EOF)
{
fprintf(file2 , "%s\n" , line);
}
fclose(file1);
fclose(file2);
}
}
Comments
Post a Comment