永发信息网

C++中怎么向一个文本文件追加到另一个文本文件内容的末尾。帮忙把程序填写完。

答案:2  悬赏:50  手机版
解决时间 2021-01-23 00:23
  • 提问者网友:锁深秋
  • 2021-01-22 19:18
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
ifstream ifile(_______________);
if(!ifile)
{
cout<<"abc.txt canʹ′t open!"<<endl;
return ‐1;
}
ofstream ofile;
ofile.open(_______________);
if(!ofile)
{
cout<<"xyz.txt canʹ′t open!"<<endl;
return­‐1;
}
char ch;
ofile.seekp(0,ios::end);
while(ifile._______________)
ofile._______________;
ifile._______________;
ofile._______________;
return 0;
}
最佳答案
  • 五星知识达人网友:孤独入客枕
  • 2021-01-22 20:00
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
ifstream ifile("abc.txt ");
if(!ifile)
{
cout<<"abc.txt can?′t open!"<<endl;
return -1;
}
ofstream ofile;
ofile.open("xyz.txt");
if(!ofile)
{
cout<<"xyz.txt can?′t open!"<<endl;
return -1;
}
char ch;
ofile.seekp(0,ios::end);
while(ifile.eof()==0)
{
ifile>>ch;
ofile<<ch;
ofile.seekp(0,ios::end);
}
return 0;
}
全部回答
  • 1楼网友:人類模型
  • 2021-01-22 20:16
将 in.txt 的内容连接到 out.txt 的末尾 #include #include #include using namespace std; int main() { ifstream ifile; ifile.open("in.txt"); ofstream ofile; ofile.open("out.txt",ofstream::app); string str; while(ifile>>str)ofile<
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯