首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

复制资料中的内容到另一个文件

2012-11-05 
复制文件中的内容到另一个文件// CString.cpp : Defines the entry point for the console application.//

复制文件中的内容到另一个文件

// C   String.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include<iostream>#include<fstream>#include<cstring>int main(int argc, char* argv[]){using namespace std;char arrstr[1024]  ;ifstream in;ofstream out;in.open ("studentInfo.txt");out.open ("studentInfo1.txt");if(in.fail()){cout<<"open file failed";exit(1);}if(out.fail()){cout<<"open file failed";exit(1);}int i = 0;while( !in.eof() ){in.getline(arrstr,1024);out<<arrstr<<endl;i++;}cout<<i<<endl;return 0;}


 

最后输出读取的行数

热点排行