#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
ifstream inf("c:\\aa.txt");
while (!inf.eof())
{
char ch;
inf.get(ch);
cout<<ch;
}
inf.close();
return 0;
}
//---------------------------------------------------------------------------
//示例2,将输入的字符串写入一个TXT文件:
//---------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(void)
{
string wd;
ofstream outf("c:\\aa.txt");
cin>>wd;
outf<<wd;
outf.close();
return 0;
}