因此,我正在编写一个函数来读取文件并将其内容放入另一个文件中。这是我迄今为止所得到的:读取文件并将其内容写入另一个C++
void myFile::printWords(string input, string output) {
ifstream file(input.c_str());
ofstream file_out(output.c_str());
string word;
if(!file.is_open())
{
printf("File can't be opened\n");
exit(o);
}
while(file >> word) {
cout<< word << '\n';
}
file.close();
}
问题是如何继续写入文件?
为什么不使用你的平台的复制文件的功能? – cdhowie 2014-11-24 23:37:21
这是如何回答这个问题的? – dwvaxaz 2014-11-24 23:41:08
我不记得'std :: ofstream(output)<< std :: ifstream(input).rdbuf())'现在是否有效,或者它仍然是两行或三行。可能是单独的行。 – 2014-11-24 23:43:53