Im trying to find the last line in a file and the last word in the line. if the last word has space . or , after it i have to get rid of it. This doesnt work
string wordfromline( string line ) {
istringstream ss( line );
// read words from ss
// return the last
}
string lastword(ifstream& file)
{
string word( "" );
string line;
while ( getline( file, line ) ) {
string lastword = wordfromline( line );
if ( ! lastword.empty() ) {
word = lastword;
}
}
// prune trailing dot or comma from word
return word;
}