SFML , exception error , Access violation reading location 0x00000281A97CA000 , C++

  access-violation, c++, exception, sfml

I’ve read those 2 threads before posting, which are similar to my problem :

I’am fairly new to C++ and I started using SFML library to make a small game. I can compile the code without any problem but then , while debugging/trying to load an image from a file in my system I always get an exception error like this :


Exception thrown at 0x00007FFA0A37146C (vcruntime140.dll) in Projecto_teste.exe: 0xC0000005: Access violation reading location 0x00000281A97CA000.


Since the code is very simple it’s easy to spot where to problem is , whoever I don’t know how to fix it.
I initially thought it could be the path name, so I tried different things , but it seems to be something more complex envolving memory handling.

#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;

int main()
{
    RenderWindow window(VideoMode(320, 400), "Tetris!");

    Texture t;
    t.loadFromFile("C:/Users/Simon/source/repos/Projecto_teste/images/tiles.png"); // Where the problem happens

    Sprite s(t);


    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }

        window.clear(Color::White);
        window.draw(s);
        window.display();
    }

    return 0;
}

Any lights on how to handle this would be great.
Thanks !

Source: Windows Questions C++

LEAVE A COMMENT