main must return int (not void).
You are missing a closing brace.
"five" is a strange name.
datum is spelled with a u.
See comments in program.
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
struct five {
float column1, column2;
};
// Does not need to be a friend of five since five's data are public.
istream& operator >> (istream& ins, five& r) {
ins >> r.column1 >> r.column2;
return ins;
}
int main(){
ifstream input( "data.txt" );
if ( !input )
{
cerr << "Cannot open file\n";
exit( -1 );
}
vector<five> data;
five datum;
// If you test for eof, THEN read (and don't test again right
// after) you will add an extra element to the end of the vector.
// So test for eof something like this.
while ( input >> datum )
{
data.push_back (datum);
}
// This loop displays the data.
// You can be modify it to sum the data instead.
for( size_t i = 0; i < data.size(); ++i )
{
cout << data[i].column1 << ", " << data[i].column2 << endl;
}
}