I am trying to understand what exactly the following function is doing. It is used to read a text file into a struct , called AEntry
, which only contains four ints.
The file contains a list of lines. Each line holds four ints delimited with spaces (or tab ).
when this function is called, a line of istream
and a AEntry
struct
are passed in.
My question is how the delimitors, spacess or tabs, are filtered out? or my understanding is wrong.
istream& operator>>( istream &stream, AEntry& val )
{
stream >> val.kv;
stream >> val.col;
stream >> val.bo;
stream >> val.Offset;
return stream;
}
They're filtered out because that's the behavior of the default overloads of istream::operator>>
. They stop at whitespace and discard it instead of incorporating it into the extracted output.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.