I want to split and get digits from a string with whitespaces

I'm trying do a homework. I have Book class and it has int* listOfYears. i need to give years by using istream& operator>> in form of string, then i need to get years between whitepaces. i could not find a solution to get digits till whitspaces. please help me.