Loading
April 24, 2014, 09:14:38 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: User input whenever he wants to?  (Read 722 times)
Waaaay0ff
Newbie
*
Posts: 12


« on: August 03, 2009, 08:17:57 AM »

We use console input (cin) for input right? well but with this code:

cin >> x;
for (int i = 0;i<100;i++) {
Sleep(2000);
cout << i << " ";
}

The user has to input something for the for loop to execute.

How can i write a code where the user can input whenever he wants to? In the previous example the user has time (since i used Sleep()) to input, the output isn't instantaneous. So what do i use so that whenever the user feels like it he can input something? And not only be able to input when the program reaches a cin statement.

Also, if i want the user to click escape, how can i do that?

Also, how do i prompt the user for mouse clicks??


Lots of questions i know Tongue
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 956



« Reply #1 on: August 03, 2009, 08:55:01 AM »

You can't do those things in standard C++. You need to use a GUI library like Win32.

Also, you don't prompt the user for mouse clicks. This video shows how to handle mouse clicks.

http://xoax.net/comp/cpp/win32/Lesson7.php

Mike
Logged
Waaaay0ff
Newbie
*
Posts: 12


« Reply #2 on: August 04, 2009, 08:09:40 AM »

oh.. Time for some win32 then!

Thanks!
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!