您的位置:首页 > 其它

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

2012-10-24 20:44 218 查看
// 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;
}




最后输出读取的行数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: