Can anyone explain the auto update_width = [&longest](string const& curr){}
I was confused the way function declared and confused how function iterating data inside the file. File has a string of words and program finds the longest words which has most match of "aceimnorsuvwxz".
ifstream ifs("../data/letter.txt");
if (!ifs) return -1;
string longest;
auto update_with = [&longest](string const& curr)
{
if (string::npos == curr.find_first_not_of("aceimnorsuvwxz"))
longest = longest.size() < curr.size() ? curr : longest;
};
for (string curr; ifs >> curr; update_with(curr));
cout << longest << endl;
return 0;