下列代码当return false后seekg(ios::beg)不起作用?
请问如何解决?
ifstream enWord::wordList("word\\wordlist");
bool enWord::Exist(string aimWord)
{
string searchWord;
wordList.seekg(ios::beg);
while(wordList>>searchWord)
{
if(aimWord==searchWord)
return true;
cout<<searchWord<<endl;
}
return false;
}
bool enWord::Exist(string aimWord)
{
string searchWord;
wordList.clear();
wordList.seekg(0, ios::beg);
...
}
void clear ( iostate state = goodbit );
Set control states.
Sets a new value for the control state ignoring the existing value
???
楼上能否解释下??
怎么可能存在fail呢?
怎么可能存在fail呢?
~~~~~~~~~~~~~~~~
while(wordList>>searchWord) 什么时候结束呢?
seekg前:if(!wordList) wordList.clear();