#define _LL_BUFFSIZE_ 2048
string lastLine;
lastLine.clear(); // regardless, zero out our return string
char buff[_LL_BUFFSIZE_]; // our temporary input buffer
data_filet.seekg (0, ios::end); // go to end of file
int length = data_filet.tellg(); // find out how large it is
data_filet.seekg(length-min(length,_LL_BUFFSIZE_),ios::beg); // seek back from end a short ways
// read in each line of the file until we're done
buff[0]=0;
do{if (!isspace(buff[0]) && buff[0] != 0)
lastLine = buff;
} while (data_filet.getline(buff, _LL_BUFFSIZE_));
cout <<"last ="<< lastLine << endl;//Last line of t stored as
cout << typeid(lastLine).name() << endl;
I use this code to read the last line of a csv file and the value of lastLine is
"29.27,83.37,39,43" etc. The number of values changes everything. I need to find a way to store this string as an array of those numbers. Where say t[0]=29.27 and t[1]=83.83 and so on. Thanks!