一道简单的题目,帮忙看下
题目:编写一个程序,统计一个文件中字符的数目。
我写的如下,编译时候不提示错误,可是什么结果也没有,为什么啊?
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream inout;
inout.open("city.txt",ios::in);
inout<<"Beijing"<<" "<<"Shanghai"<<" "<<"Zhengzhou";
inout.close();
inout.open("city.txt",ios::out);
char city;
int count=0;
while (!inout.eof())
{
city=inout.get();
count++;
}
cout<<count<<endl;
inout.close();
return 0;
}