before i started learning c++ i learned visual basic and in it there was a type of thing to do key press how do i do it in c++ to where its like
cout<<"Enter commmand"<<endl;
//user presses a
cout<<"You enterd a"<<endl;
something like that
before i started learning c++ i learned visual basic and in it there was a type of thing to do key press how do i do it in c++ to where its like
cout<<"Enter commmand"<<endl;
//user presses a
cout<<"You enterd a"<<endl;
something like that
- 0927
- a.k.a 0 9 two 7
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
char key;
key=getch();
cout<<"you entered "<<key<<endl;
system("PAUSE");
return 0;
}
or this...
#include<stdio.h>
#include<iostream.h>
main(){
cout << "Enter a character: ";
getche();
}
//the getche() function automatically outputs the pressed character to the screen.
Yoshi