I am trying to add the contents of multiple files over to another file, but I am having trouble. It seems that every time I add the contents of one file, it overwrites the contents of the last file I added. Here is my code:
cout << "Enter Directory Location" << endl;
string name;
getline(cin, name);
cout << "Directory: " << name << " Used" << endl;
name += "/title";
int x = 1; // I am assuming that the file number will simply start at 1
int y;
cout << "Enter Number of Files" << endl;
cin >> y;
while(x <= y)
{
stringstream sstm;
sstm << name << x;
name = sstm.str();
name += ".png";
ifstream binfile(name.c_str(),ios::in | ios::binary);
myfile << binfile.rdbuf();
x++;
}
As always, I appreciate any help!