SFML community forums

Help => Window => Topic started by: Xyst on February 18, 2014, 11:57:46 pm

Title: std::cin causing crash
Post by: Xyst on February 18, 2014, 11:57:46 pm
I've got this weird problem: whenever I try to get input to my code, the window crashes.



#include <iostream>
#include <SFML/window.hpp>

int main() {
    char myChar;

    sf::Window window( sf::VideoMode(200, 200),"window");

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {

            if (event.type == sf::Event::Closed)
                window.close();
        }

        std::cin >> myChar;
    }
}
 

I got SFML 2.1, and I am using Code::Blocks 13.12
Title: Re: std::cin causing crash
Post by: eigenbom on February 19, 2014, 08:08:10 am
cin blocks. You'll want to use sfml's key events to get input. The tutorials show how.
Title: Re: std::cin causing crash
Post by: Xyst on February 19, 2014, 09:39:59 pm
Thank you, that solved my problem!