Q:

Incrementing Individual Characters in String

I dont know if I have the correct tiltle for this, so please correct me if I am wrong and I will change my title.
I have a string, for this example I will use:
"8ce4b16b"

I would like to shift the bits (I think) along 1 so the string would be:
"9df5c27c"

Any Ideas?
EDIT:
Just so you know, these strings are hex. So it will never reach z.
All I want to do is add a number to the numbers and progress one step through the alphabet so a->b, f->g ect ect
If the number is 9 there will be a condition to keep it as 9.
The output DOES NOT need to be a hex.
Also the string is only an example. It is part of an MD5 encryption.

A:

Transform a string? This sounds like a job for std::transform():
#include <cassert>
#include <string>

char increment(char c)
{
    if ('9' == c)
    {
        return '9';
    }
    return ++c;
}

std::string increment_string(const std::string& in)
{
    std::string out;
    std::transform(in.begin(), in.end(), std::back_inserter(out), increment);
    return out;
}

int main()
{
    assert(increment_string("8ce4b16b") == "9df5c27c");
    assert(increment_string("ffffffff") == "gggggggg");
    assert(increment_string("89898989") == "99999999"); // N.B: this is one of 2^8 strings that will return "99999999"
    assert(increment_string("99999999") == "99999999"); // This is one more. Mapping backwards is going to be tricky!
    return 1;
}

Any limits you wish to impose on the characters can be implemented in the increment() function, as demonstrated.
If, on the other hand, you wish to treat the string as a hexadecimal number and add 0x11111111 to it:
#include <sstream>
#include <cassert>

int main()
{
    std::istringstream iss("8ce4b16b");
    long int i;
    iss >> std::hex >> i;
    i += 0x11111111;
    std::ostringstream oss;
    oss << std::hex << i;
    assert(oss.str() == "9df5c27c");
    return 1;
}

No bits were shifted in the construction of this string.

A:

Do you mean you want to increment each character in the string?
You can do that my iterating through the array and adding one to each character.

