An fstream
object is not copyable. Pass by reference instead: fstream&
:
void vowel(fstream& a)
Note you can avoid the call to open()
by providing the same arguments to the constructor:
fstream a("temp.txt", ios::in);
and don't use while(!a.eof())
, check the result of read operations immediately. The eof()
will only be set when an attempt is made to read beyond the last character in the file. This means that !a.eof()
will be true when the previous call to get(ch)
read the last character from the file, but subsequent get(ch)
will fail and set eof but the code won't notice the failure until after it has processed ch
again even though the read failed.
Example correct structure:
while (a.get(ch)) {
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…