When you use getch() what are the chars for the errors?
EDIT: I'm using C++, MSVS
When you use getch() what are the chars for the errors?
EDIT: I'm using C++, MSVS
Last edited by GreenCherry; 10-04-2002 at 09:30 AM.
bump
I have a rabbit in my pants! Please be happy for me.
took me a long time to make this...
¿Red Baron?
"Imagination is more important than knowledge"
-Albert Einstein (1879-1955)
Check out my games!
[code] /* dont forget code tags! */ [/code]
how would you use this?
Would you just compare the int returned with the value provided?
Does it work with getche()?
I am using DEV, if that effects it.
Compilers:
GCC on Red Hat 8.1 (Primary)
GCC on Mac OS X 10.2.4 (Secondary)
Others:
MinGW on XP
Code:<headers...> #include "keys.h" int main() { int keys; keys=my_getch(); if (keys==K_LEFT) { printf("left key was pressed"); } system("PAUSE"); return 0; } int my_getch () { int input=getch(); if (input==224) input=getch(); else if (input==0) input=256+getch(); return input; }
btw its been a lil while since i last programmed so there might be a small mistake havn't compiled yet should work with dev-c++ (waht i use)
¿Red Baron?
"Imagination is more important than knowledge"
-Albert Einstein (1879-1955)
Check out my games!
[code] /* dont forget code tags! */ [/code]
Btw, look up the function kbhit()...Code:#include <iostream> #include <stdlib.h> #include "keys.h" #include <conio.h> using namespace std; int move = 0; char key; int x = 0; int y = 0; int main() { do { key = getche(); move = (char)key; if(move == K_UP) y--; else if(move == K_DOWN) y++; else if(move == K_LEFT) x--; else if(move == K_RIGHT) x++; }while(move != K_ESC); system("PAUSE"); return 0; }
EDIT: It looks like I took way too long on that post before red_baron beat me out.
red_baron, TechWin... that will not work in a Win32 console... well, it will compile; But it will not work properly.
You need to use virtual keys...
http://cboard.cprogramming.com/showt...threadid=25835
I was doing that for Inquirer; for some reason I was thinking he wanted it in console for Dev.
No one answered GreenCherry
I'm guessing NULL will indicate an error with getch();
NULL = 0