How does operator>> on std::cin treat whitespace by default?
-
A
It reads a whole line including spaces
-
B
It refuses input containing spaces
-
C
It skips leading whitespace before reading
Correct answer
-
D
It keeps leading whitespace as data
Correct answer
C. It skips leading whitespace before reading
16 views
Explanation
Formatted extraction uses the skipws flag, so leading whitespace is discarded before the value is parsed.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ