'Removing the first word from a sentence and store it c++

I am reading from a file in C++, and I want to remove all but the first word and store it,

sentence = sentence.substr(sentence.find_first_of(" \t") + 
1);

this code remove the first word and keep the whole sentence , is there a way to store the removed word.



Solution 1:[1]

https://en.cppreference.com/w/cpp/string/basic_string/find_first_of take position of first match from find_first_of and then sentence start pos to position from find_first_of

std::string w1 = sentence.substr(0, sentence.find_first_of(" \t"));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nexan_pro