#include < iostream >
#include < sstream >
#include < cctype >
int main()
{
std::string s = "dsdhjsahdk dsdjdsaj 36782367 sdjdhak";
int j = 0;
std::stringstream cstr;
cstr << s;
int i = 0;
char ch;
while( cstr >> ch )
{
if( std::isdigit(ch) )
{
cstr.putback(ch);
break;
}
if( ( j = s.find(" ", j) )== std::string::npos )
{
cstr.seekg(-1);
break;
}
cstr.seekg(++j, std::ios::beg);
}
if(cstr)
{
cstr >> i;
}
std::cout << i;
return 0;
}
No comments:
Post a Comment