seperating letters and numbers from string using substr()

how can i go about using the substr() function to separate letters and numbers from a string into separate variables from a given input?

1
2
3
4
5
  string str;
cin >> str;
string sub = str.substr(0, 1) 
string sub2 = str.substr(2,2)


but what if they input one letter or maybe two? and theres always the posibility that they might put a 1 ,2 ,3 ,10 ,15 digit number. im just completely lost on this one. thanks in advance
Last edited on
Topic archived. No new replies allowed.