I have this code, where I'm creating a SFML-Text object. But when I try to put this into a function I get an error. I have a programming background in Java, and this pointer-thing confuses me.

Is this a problem caused by incorrect use of pointers/reference, or because of object not surviving the scope? Or, is it something else?

```
void createDisplayText(sf::Text *text, string content, sf::Font font)
{
    text->setFont(font);
    text->setCharacterSize(24);
    text->setString("Money: 0");
}

//Main function
sf::Text energyText;
createDisplayText(&energyText, "Energy: ", font);
energyText.move(0, 30);

//Main loop
    window.draw(energyText);

```

I get this error:

```
Unhandled exception at 0x0F58FE8C (sfml-graphics-d-2.dll) in SFML_testing.exe: 0xC0000005: Access violation reading location 0x0000000C.

```