#include <iostream>
#include <fstream>
using namespace std;
  void main() 
  {
  ofstream SaveFile("cpp.txt");
  SaveFile << "Hello World!";
  SaveFile.close();
  }
  #include <iostream>
#include <fstream>
using namespace std;
void main()
{
ifstream OpenFile("cpp.txt");
char ch;

         while (OpenFile.eof())
{
OpenFile.get(ch);
cout<<ch;
}
OpenFile.close();
}

解决方案 »

  1.   

    告诉我你要做啥?把helloworld写入一个txt文件里?
      

  2.   

    lZ请注意你循环的条件啊,要加上“!”,要不然你根本进不去这个循环啊!
    while (!OpenFile.eof())
    {
    OpenFile.get(ch);
    cout<<ch;
    }
      

  3.   

    ofstream out;
    out.open(....);
    out.write(....);
    out.close();ifstream in;
    in.open(....);
    in.read(....);
    close();给你模型,剩下的自己写吧。