What help? The code in the first post compiles, runs and produces the expected answer. I'd comment that int should be size_t as this the type returned by .length()
If you are required to use a stack, then you are required. It's not how would do it for real if required - but a lot of given exercises require things done differently as to how they would actually be done.