Search code examples
c++for-loopcompiler-errorsfstream

fstream error in compiler C++


This is a real newbie question but my compiler is giving me the error:

std::fstream has no member named getc

It is relative to this line of code:

char ch;

for ((ch=fpin.getc());!fpin.eof();(ch=fpin.getc()))

fpin is a file and I have checked for opening etc. it's fine. I'm also not worried about the quality of the code, just worried about getting it to work. I've been staring at it so long that I can't see the problem.


Solution

  • What djechlin said, but if you do want to get by character you can do ch = fpin.get(), which will grab a single character. or you can do fpin >> ch; to get a single character but ignore whitespace.