Here, unlike with the first call of find_first_not_of() in the example, the end of the previous
word is passed as the starting index for the search. If the previous word was the rest of the line,
endIdx is the index of the end of the line. This simply means that the search starts from the end of
the string, which returns string::npos.
Let’s try this “useful and important” program. Here is some possible input:4