Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: std::cin causing crash  (Read 2431 times)

0 Members and 1 Guest are viewing this topic.

Xyst

  • Guest
std::cin causing crash
« 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

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: std::cin causing crash
« Reply #1 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.

Xyst

  • Guest
Re: std::cin causing crash
« Reply #2 on: February 19, 2014, 09:39:59 pm »
Thank you, that solved my problem!

 

anything