Hello there, I need some help on how I could replace the getch() function.
Basically, my assignment was to make a simple simulated "joystick" program.
You press the letters a,b,c,d... and it will output the number pressed...
The program works and everything, but i found out im not allowed to use getch() from the conio platform because it's Borland specific... Any ideas on what can replace the getch() issue? I've tried cin.get, getline, etc... but it doesnt work the same because you have to press enter every single time. Any help is much appreciated. :-)
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
typedef void (*Func)();
void zero();
void one();
void two();
void three();
int main(int argc, char *argv[])
{
char data;
Func func[4];
func[0] = &zero;
func[1] = &one;
func[2] = &two;
func[3] = &three;
while((data = cin.getch()) != '\033')
{
if(data>='a' && data <='d')
func[(int)data-97]();
}
system("PAUSE");
return EXIT_SUCCESS;
}
void zero()
{
cout<<"Zero was pressed!!!"<<endl;
}
void one()
{
cout<<"One was pressed!!!"<<endl;
}
void two()
{
cout<<"Two was pressed!!!"<<endl;
}
void three()
{
cout<<"Three was pressed!!!"<<endl;
}