SFML community forums

Help => General => Topic started by: Austin J on November 18, 2013, 04:45:13 am

Title: sf::String::erase() troubles.
Post by: Austin J on November 18, 2013, 04:45:13 am
SFML 2.1 - Static
Windows 7 - 64 bit

No matter how I go about it, sf::String::erase() doesn't work properly for me. Whenever I use it rather than erase the character it just replaces it with a box.

(I am filtering out backspace)

sf_string.erase(sf_string.getSize()-1,1); // Results in box first press then nothing afterwards(No size change)
 

std_string1 = sf_string;
std_string1.erase(std_string1.size()-1,1);
sf_string = std_string1; // Same results
 

I've tried other ways and it doesn't matter how I go about it I get this damned box.

Any help appreciated, thanks.
Title: Re: sf::String::erase() troubles.
Post by: The Hatchet on November 20, 2013, 09:03:57 pm
From what I can tell from your code the you are telling your string to erase only the 2nd to last item in it.  If this isn't your intention maybe you should brush up on how to correctly use the str.erase() method works. String::Erase (http://www.cplusplus.com/reference/string/string/erase/)
Title: Re: sf::String::erase() troubles.
Post by: Estivo on November 20, 2013, 10:42:40 pm
try this
sf_string.erase(sf_string.end()-1);