Daniel Wilches wrote;
< How to capture only a keystroke from the keyboard?? getch(), getchar() and
<getche() doesnt seem to work how they should... This is what im doing:
<#include<iostream>
<#include<conio.h>
<void main()
<{
<cout<<"Daniel";
<getch();
<}
<and i add in further objects to be searched in the project options this:
<C:\Dev-c++\lib\conio.o
<The getch in this program continue reading keystroke until it finds a
<Return, but what i want is only to read a keystroke...
<Please, anybody can help me??
<ThanXX
<Daniel Wilches
After looking at the code the only problem I see is the use of getch(), try
writing it this way:
#include<iostream>
#include<conio.h>
void main()
{
Int ch;
cout<<"Daniel";
ch = getch();
}
What will happen is when you press any key it is stored in the variable ch,
this is very useful when event trapping in a console program.
As far as I know you should be able to modify conio.o but before doing so
make a copy of the original someplace else, E.G. Temp folder, CD, floppy,
etc. in the event that any changes would cause problems and you need to
restore the original.
Good Luck
Danny
|