SFML community forums

Help => General => Topic started by: HeliumPL on July 04, 2013, 11:02:46 pm

Title: Error while closing program
Post 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:
Code: [Select]
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:
Code: [Select]
window.draw(txt("text", 12, sf::Color::White, 0, 0));
It's causing program to crash while it's closing:
Quote
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 :)
Title: Re: Error while closing program
Post by: Nexus on July 04, 2013, 11:15:00 pm
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*.
Title: Re: Error while closing program
Post by: Laurent on July 05, 2013, 08:00:09 am
Quote
Access violation reading location 0xfeeefef6.
It means you're accessing a freed memory location (a destroyed object).