Which option ?

Hello :)
If I have a string like "ngc6910" and have converted the 6910 part to an int using the stoi function, and want now to modify the originally string, so that it contains just the number part, should I use str = to_string(convertedInt) or something like this:
1
2
3
4
5
 
int i=0;
while(!isdigit(str.at(i++))){
str.pop_back;
}


I know that both methods work, but which one uses less memory/is better to use ?
I would prefer std::to_string because it's less messy.
Topic archived. No new replies allowed.