0

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?

3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by Ancient Dragon
0

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;
}
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.