Hello,
For some reason using an sf::sleep with an std::cout and no std::endl makes my program freeze forever:
#include <iostream>
#include <SFML/System/Sleep.hpp>
int main(int argc, char ** argv)
{
while(true)
{
std::cout << "here";
sf::sleep(sf::seconds(0.5f));
}
return 0;
}
However if I remove
sf::sleep or if I add
std::cout << "here" << std::endl; it works just fine. In addition, this was compiled in Ubuntu 12.04 (64-bit) with g++ 4.6.3, but for some reason the problem doesn't seem to happen in Windows (compiled with mingw/g++ 4.8 ).
What could be the problem here?
Thanks in advance,
Best regards
EDIT: Adding a std::cin.ignore(std::numeric_limits<int>::max(),'\n'); also seems to fix the problem for a while. This leads me to believe it could be a buffer problem? But why does sf::sleep affect this?
EDIT: Adding an std::flush also seems to work.