[求助]c++的问题
为什么下面的函数中if()语句不能运行,而是去运行else中的语句呢?#include<iostream>
#include<fstream>
using namespace std;
void main()
{
char ch;
ifstream tfile ("payroll",ios_base::binary);
if(tfile)
{
while(tfile.good())
{ streampos here=tfile.tellg();
tfile.get(ch);
if(ch==' ')
cout<<"Position "<<here<<"is s space"<<endl;
}
}
else
cout<<"ERROR:Cannot open file 'payroll'."<<endl;
tfile.close();
}