I have overloaded operator >>
and I am trying to read a data from a file, i.e.
Store first;
std::wifstream in("file.txt");
in >> first;
Here is the code:
std::wistream & operator >> (std::wistream &is, Store &store)
{
std::size_t vec_size; // size of employees_ vector
std::getline(is, store.name_);
is >> store.surface_area_;
std::wcout << store.surface_area_ << std::endl;
is >> vec_size;
std::wcout << vec_size << std::endl;
...
return is;
}
name_
is of type wstring
surface_area_
is of type double
file.txt:
Euro AGD
1154,5
0
0
(I have set Polish $LANG, that's why there is comma instead of a dot)
And what I get is:
1 154,5
4 519 717 136
If I add is.ignore()
right after getline I get:
154,5
0
My guess is that getline
is causing a mess in a buffer. How to make this work?