I have this function that should open two files and write their content in a third file, separated by "\n". I don't get why it works for code in comments and not for the one below it, although both provide valid text file names.
void concatenate()
{
/*char *file=new char[strlen(" ")+strlen(mFile)];
strcpy(file,"\0");
file=strcat(file," ");
file=strcat(file,mFile);*/
char *file=new char[strlen("aux.txt")];
strcpy(file,"aux.txt");
FILE *f=fopen(file,"w");
FILE *f1=fopen(F.getFile(),"r");
FILE *f2=fopen(mFile,"r");
char s[100];
while (!feof(f1))
{
fgets(s,100,f1);
fseek(f,0,SEEK_END);
fprintf(f,s,"%s");
}
fclose(f1);
fprintf(f,"\n","%s");
while (!feof(f2))
{
fgets(s,100,f2);
fseek(f,0,SEEK_END);
fprintf(f,s,"%s");
}
fclose(f2);
fclose(f);
}