分别写C和C++程序,讲文本文件old.txt中的所有内容拷贝到新文件new.txt中

[复制链接]
查看11 | 回复1 | 2011-3-4 23:24:29 | 显示全部楼层 |阅读模式
很急~~ 谢谢了

回复

使用道具 举报

千问 | 2011-3-4 23:24:29 | 显示全部楼层
C++版本#include#include#includeusing namespace std;int main(){ ofstream out("new.txt"); fstream in; in.open("old.txt",ios::in); if(!in)//如果old.tx不存在 {cout<<"文件old.txt不存在!"<<endl;return 0; } cout<<"复制中..."<<endl; for(string str;getline(in,str);)out<<str<<endl;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行