>> double std::vector.
std::vector - .
, , 2 :
std::ifstream inputFile{"/home/shared/data4.txt"};
std::vector<double> rainfall{std::istream_iterator<double>{inputFile}, {}};
Another solution is to define an input operator function as:
std::istream& operator>> (std::istream& in, std::vector<double>& v) {
double d;
while (in >> d) {
v.push_back(d);
}
return in;
}
Then you can use it as in your example:
std::vector<double> rainfall;
inputFile >> rainfall;
source
share