Hello, anyone familiar with ansiString?

Have a problem involving a string "1 1", should read "11".

I want to get rid of the space in the middle. Can't change it to a character string or std::string so that isn't an option. Will i have to compare each character inturn with " "?

Using ansiString.Pos(" ") to get position of the " ", but how should i go about removing the space and replacing it with the next character?

OK here is what I've got at the minute:

String fixString(inputString)
{
    result = inputString;
    int string_size = result.Length();
    while(result.Pos(" "))
    {
        int space = result.Pos(" ");
        for (int i = space; i < string_size; i++)
        {
             result[space] = result[space+1];
             string_size--;
        }
    }
    result.SetLength(string_size);
    return result;
}

Isn't std::string the ANSI string?

Why are you not using std::string? If you were you could just do...

result.erase(result.find(' '));

To remove one space...

-Fredric

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.