G
Glen
i get segmentation fault when i execute the following code(the
platform is gnu/linux)
#include<stdio.h>
int main()
{
char fn1[50],fn2[50],tn[50];
printf("\nEnter the first file name :");
scanf("%s",fn1);
printf("\nEnter the second file name :");
scanf("%s",fn2);
printf("\nEnter the target file name :");
scanf("%s"tn);
jfilejoin(&fn1,&tn);
jfilejoin(fn2,tn);
return 0;
}
int jfilejoin(char *fname,char *tfname)
{
FILE *in,*out;
int i,ch;
if((out=fopen(tfname,"a"))==NULL)
out=fopen(fname,"w");
in=fopen(fname,"r");
while(!feof(in))
{
ch=fgetc(in);
if(!feof(in))
fputc(ch,out);
}
fclose(in);
fclose(out);
return 0;
}
kindly help.this pgm is supposed to join two files to the target
filename.this is a module of a multithreaded download manager;-)
thanx
platform is gnu/linux)
#include<stdio.h>
int main()
{
char fn1[50],fn2[50],tn[50];
printf("\nEnter the first file name :");
scanf("%s",fn1);
printf("\nEnter the second file name :");
scanf("%s",fn2);
printf("\nEnter the target file name :");
scanf("%s"tn);
jfilejoin(&fn1,&tn);
jfilejoin(fn2,tn);
return 0;
}
int jfilejoin(char *fname,char *tfname)
{
FILE *in,*out;
int i,ch;
if((out=fopen(tfname,"a"))==NULL)
out=fopen(fname,"w");
in=fopen(fname,"r");
while(!feof(in))
{
ch=fgetc(in);
if(!feof(in))
fputc(ch,out);
}
fclose(in);
fclose(out);
return 0;
}
kindly help.this pgm is supposed to join two files to the target
filename.this is a module of a multithreaded download manager;-)
thanx