Problem Related to C++ SFML Programming

I have already copied the image needed to the same file with the program.
But when I run the program, the system shows
Failed to load image "Untitled.jpg". Reason : Unable to open file
Why?
The code that I used are as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<SFML/Graphics.hpp>
#include<SFML/Window.hpp>

using namespace std;

int main ()
{
    sf::RenderWindow window(sf::VideoMode (800, 600), "My window");
    sf::Texture myTexture;
    if(!myTexture.loadFromFile("Untitled.jpg"))
        return 1;
    sf::Sprite sprite;
    sprite.setTexture(myTexture);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close ();
        }
     window.clear(sf::Color(200, 0, 0));
     window.draw(sprite);
     window.display();

    }

    return 0;
}
Do you have that image file in the same directory as the executable?
Reply: ResidentBiscuit
Yes, already saved in the same folder.
Topic archived. No new replies allowed.