#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <fstream>
#include <string>
//Линия в файле. Стоит дать полям боле осмысленные имена, но для примера сойдет
struct Line{
std::string first;
int second;
int third;
double fourth;
};
//Оператор чтения линии из файла
std::istream& operator>>(std::istream &is, Line &line){
is >> line.first;
is >> line.second;
is >> line.third;
is >> line.fourth;
return is;
}
//Функциональный объект, для того чтобы можно было вынуть из Line последнее значние
struct LineFourth{
inline double operator()(const Line &line) const{
return line.fourth;
}
};
int main(int, char*)
{
std::vector<double> values;
std::ifstream file("data.txt", std::ifstream::in);
if(!file){
//Не удалось открыть файл
return 1;
}
std::istream_iterator<Line> begin(file);
std::istream_iterator<Line> end;
//Чтение файла построчно. В values будет помещен последний столбец
std::transform(begin, end, std::back_inserter(values), LineFourth());
//Дальше можно что-то делать с values
return 0;
}