自考新教材-p327_4(1)

源程序:

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
char k;
int i;
ofstream outf("c:\\tmp\\tem.dat",ios::trunc);
outf << "Hello world.";
outf.close();

ifstream inf("c:\\tmp\\tem.dat");
char str[100];
while((k=inf.get())!=EOF)
cout << k << endl;
inf.close();
system("pause");
return 1;
}

运行结果:

 

posted @ 2020-02-05 18:47  bobo哥  阅读(178)  评论(0编辑  收藏  举报