// c++文件流.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <stdlib.h>
//using namespace std;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
/*std::ofstream out("text.txt");
while(out.is_open())
{
out<<"hello world!"<<std::endl;
out<<"good afternoon!"<<std::endl;
std::cout<<"hello world!";
out.close();
}*/
ifstream in("text.txt");
char buffer[255];
//char *buffer2=NULL;
ofstream out("test_ifream.txt");
if(!in.is_open())
{
cout<<"wrong text!"<<endl;
exit(1);
}
int i=1;
while(!in.eof())
{
//注意,是buffer不是in
in.getline(buffer,100);
out<<buffer<<endl;
cout<<buffer<<endl;
}
system("pause");
return 0;
}