我想將多個文件的內容添加到另一個文件中,但我遇到了問題。似乎每次添加一個文件的內容時,它都會覆蓋我添加的最後一個文件的內容。這裏是我的代碼:將來自多個文件的信息添加到一個文件中C++
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++;
}
一如既往,我感謝任何幫助!
IOS: :追加,也許? –