Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
std::istream::ignore 丢弃字符,直到一个比较等于 delim。是否有另一种处理字符串而不是字符的方法,即丢弃字符串直到一个比较等于指定的字符串?
最简单的方法是不断提取字符串,直到找到正确的字符串:
std::istringstream iss; std::string str; std::string pattern = "find me"; while ( iss >> str && str != pattern ) ; if (!iss) { /* Error occured */ }
当然,这假定字符串是用空白字符分隔的。