自考新教材-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;
}
运行结果: