SFML community forums
Help => General => Topic started by: HeliumPL on July 04, 2013, 11:02:46 pm
-
Hi!
I've made a simple function in SFML 2.0 to write some text on screen:
sf::Text txt(char* text, int size, sf::Color color, int x, int y)
{
sf::Text txt;
txt.setFont(font);
txt.setString(text);
txt.setCharacterSize(size);
txt.setColor(color);
txt.setPosition(x, y);
return txt;
}
Of course it's displayed this way:
window.draw(txt("text", 12, sf::Color::White, 0, 0));
It's causing program to crash while it's closing:
Unhandled exception at 0x76fb59a6 in Offensive.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
I know that I made a stupid mistake ;D Please help me :)
-
Please read this thread (http://en.sfml-dev.org/forums/index.php?topic=5559.0) carefully; it helps us to understand your problem better, and you to get more answers.
And you shouldn't use char* for string literals, use const char*.
-
Access violation reading location 0xfeeefef6.
It means you're accessing a freed memory location (a destroyed object).