Hey everyone, I have got a question. Why does this code cause segfault?
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
{
std::cout << 1 << std::endl;
sf::Text text;
std::cout << 2 << std::endl;
text.setString("Hello world");
std::cout << 3 << std::endl;
}
std::cout << 4 << std::endl;
}
After successfully compilation (and run) with this command:
g++-7 -std=c++17 -c main.cpp&&g++-7 main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system&&./sfml-app
It prints me:
1
2
3
Naruszenie ochrony pamięci
Naruszenie ochrony pamięci is Segmentation fault in polish
I use Linux Mint 64bit