如何从字符串中获取单词

Mar*_*ewa 1 c c++

我有"我在做护士工作".我如何使用哪个函数从1号字母到空格或11号字母?

所以我应该"正在工作"

Mar*_*ork 7

要从流中读取单词,请在字符串上使用operator >>

std::stringstream  stream("I am working as a nurse.");
std::string  word;

stream >> word;  // word now holds 'I'
stream >> word;  // word now holds 'am'
stream >> word;  // word now holds 'working'
// .. etc
Run Code Online (Sandbox Code Playgroud)