sf::Texture texture; texture.loadFromFile("sprite.png"); sf::Sprite sprite(texture); sprite.setPosition(200, 300);
sf::Font font; font.loadFromFile("arial.ttf"); sf::Text text("Hello, world!", font, 24); text.setPosition(100, 100);Here, we load a font file and create a text object with the message "Hello, world!" and a font size of 24. Then, we use setPosition() to set the position of the text to (100, 100) on the screen. Package/library: SFML library for C++