Search code examples
c++whitespaceistream

Will istream::get() with no parameters return whitespace?


This seems like a really simple question, but I can't find the answer anywhere. If I'm parsing a file (that includes newline characters) character by character, using

char next = file.get();

will the following check ever be true?

if (next == '\n')

Solution

  • Yes. It gets the next character from the stream. It does not skip newlines or whitespace.