I\'m trying to parse a simple string in C++. I know the string contains some text with a colon, followed immediately by a space, then a number. I\'d like to extract just t
Similar to Konrads answer, but using istream::ignore:
istream::ignore
int number; std::streamsize max = std::numeric_limits::max(); if (!(std::cin.ignore(max, ':') >> number)) { std::cerr << "No number found." << std::endl; } else { std::cout << "Number found: " << number << std::endl; }