Is this a console program? That kind of thing is better suited to windowed programs, but you can do it easily if you want:
#include <iostream>
#include <iomanip>
#include <climits>
#include <windows.h>
int main()
{
int count = 0;
for ( ; ; ) {
if ( GetAsyncKeyState ( VK_ESCAPE ) != 0 )
break;
else if ( GetAsyncKeyState ( VK_UP ) & SHRT_MAX ) {
if ( count < 100 )
++count;
}
else if ( GetAsyncKeyState ( VK_DOWN ) & SHRT_MAX ) {
if ( count > 0 )
--count;
}
std::cout<< std::setw ( 3 ) << count <<"%\r";
Sleep ( 100 );
}
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401