string::find_last_not_of("0123456789")
and then
string::substr()
that gives you the position of the last non digit/number. Just take all the preceding characters and that is the base name.
Increment by one to get the start of the number sequence at the end of the string.
Note: no error checking or other tests.
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string test = "hellothere4";
size_t last_char_pos = test.find_last_not_of("0123456789");
string base = test.substr(0, last_char_pos + 1);
EDIT
there is a problem with ALL the solutions when your "base name" has a number at the end.
for example, if the base string is "base1" then you can never get the proper base name. I assume you already are aware of this.
Or am I missing something? As long as the base name can't have a number at the end just before the postfix number it will work fine.