small key pressing issue

Hey guys, newbie here.
I had a problem with some really small code I was trying to test.
My aim here is that in the console, 4 variables are being displayed as 0s, and all I have to do is press and hold down arrow keys in order for them to take the value 1, and upon letting go, turn back to 0.
I just recently got onto linux, and as it seems in my code,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  //Arrows turn 0's into 1's
#include <iostream>
using namespace std;

int main()
{
  bool a=0, b=0, c=0, d=0;
  while(/*code here that stops the loop upon pressing the A key*/)
    {
      cout<<"\r"<<a<<"     "<<b<<"     "<<c<<"     "<<d;
        /*if(up arrow is pressed){ a=1 }
        if(right arrow is pressed){ b=1 }
        if(left arrow is pressed) { c=1 }
        if(down arrow is pressed) { d=1 }*/
    }
  cout<<endl;
  return 0;
}

I'm trying to find a way to use if statements in an endless while loop in order to change the values of the 4 bools stated above.
I saw that the equivalent in Windows was GetKeyState() or GetAsyncKeyState(), however, what is the equivalent in Linux?
There isn't.

If you are writing a TUI program, use NCurses.
If you are writing a GUI program, you'll need to read the documentation for your graphical toolkit, or use the X library keyboard routines directly.
Got it, thanks.
Topic archived. No new replies allowed.