Constantly updating cin statement in C++

I am creating an rpg style text game in C++. The game is running in
a constant game loop that updates the screen 10 times per second.
I am trying to figure out how the user can enter in input while the
game loop updates so that there is no pause during the game battles.
If anyone knows of a cin statement that doesn't stop the program every
time it is called that would be great! Any other ideas on how I can bypass
this problem would be fantastic!
You can't use streams for that. You need to use a library such as (n|pd)curses to do that.
Try something like this

while ( 1 > 0)
{
bool done = false;
while(!done){DWORD dwMilliseconds = 50;
Sleep ( dwMilliseconds );
if(GetAsyncKeyState(VK_CONTROL) != 0 )
{
cout << "you see this because you hit control" <<endl;
done = true;
}
See http://www.cplusplus.com/forum/articles/28558/.
By the time you finally figure out how to overcome some of the limitations of the console in order to use it for something it has never been intended for, you could have already finished your game.
Thank you bzb95 for the code. I can work with that to optimize it for my project. Thanks to everyone else for taking the time to help!!!
@ bzb65 while ( 1 > 0 )? why not while (true)?

Also, hugely agree with Bazzy and Athar. If you're making a game, use a library, and ultimately,if you want a process to run simultaneously alongside another, start a new thread.

Topic archived. No new replies allowed.