...
In this example, the first read will not overflow, but could fill bufOne
with a truncated string. Furthermore, the second read still could overflow bufTwo
. The C++ Standard, [istream.extractors], paragraphs 7–9 [ISO/IEC 14882-2014], describes the behavior of operator>>(basic_istream &, charT *)
and, in part [ISO/IEC 14882-2014]part, states the following:
operator>>
then stores a null byte (charT()
) in the next position, which may be the first position if no characters were extracted.operator>>
then callswidth(0)
.
...