when appending a file to another weird symbols appear at the end and it's ascii is -1, and if there another way to add a file to the other please share
void AddFile(char old_name[],char old_content[]) {
ofstream old_file;
ifstream new_file;
char new_name[255];
int len, f_begin, f_end;
cout << "Enter the file name: ";
cin.ignore();
cin.getline(new_name,255,'\n');
strcat(new_name, ".txt");
new_file.open(new_name);
f_begin = new_file.tellg();
new_file.seekg(0,ios::end);
f_end = new_file.tellg();
new_file.seekg(0);
len = f_end - f_begin;
char new_content[len+1];
new_content[len] = '\0';
for (int i=0; i< len; ++i) {
new_content[i] = new_file.get();
}
new_file.close();
strcat(old_content,"\n");
strcat(old_content,new_content);
old_file.open(old_name);
cout << old_content;
old_file << old_content;
old_file.close();
}
the .tellg() function gives the correct size