Search This Blog

Saturday, 24 November 2012

getch()


#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
cout<<"Hi"<<endl;
getch();         //Screen is paused till the user presses a button.
cout<<"By"<<endl;
}

=========================================================================================

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
cout<<"Hi"<<endl;
int a = getch();         //Screen is paused till the user presses a button and that pressed button's ASCII will be stored in a.
cout<<a;
}

Did you see how useful is it?
Once you have stored the ASCII value, you can compare it. Let me clarify what I mean.


#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
cout<<"Hi"<<endl;
int a = getch();         //Screen is paused till the user presses a button and that pressed button's ASCII will be stored in a.
if (a == 97)
cout<<"How dare you to press \"a\""<<endl;
else
if (a == 98)
cout<<"How dare you to press \"b\""<<endl;
else
cout<<"You pressed a key other than A and B."<<endl;
}



11 comments:

  1. I'm gone to say to my little brother, that he should also pay a visit this webpage on regular basis to get updated from most up-to-date news update.

    Feel free to visit my web-site: vocal classes online

    ReplyDelete
  2. We're a group of volunteers and starting a new scheme in our community. Your website offered us with valuable info to work on. You've done a formidable job and our whole community
    will be thankful to you.

    Feel free to surf to my homepage ... stream from your computer stream from your computer

    ReplyDelete
  3. Hello, its fastidious paragraph regarding
    media print, we all be aware of media is a enormous source of information.


    my webpage :: understanding dslr camera settings

    ReplyDelete
  4. I like the valuable information you provide in
    your articles. I'll bookmark your blog and check again here frequently. I'm quite certain I'll learn a lot of new stuff right here! Good luck for the next!

    Also visit my webpage how to belly dance better

    ReplyDelete
  5. Hello, for all time i used to check website posts here early in the break
    of day, because i like to learn more and more.

    Feel free to visit my web-site; hair Removal Products

    ReplyDelete
  6. Great article, exactly what I was looking for.


    Look into my site learn to play the fiddle

    ReplyDelete
  7. We are a group of volunteers and opening a new scheme in
    our community. Your website offered us with valuable information to work on.
    You've done a formidable job and our entire community will be thankful to you.

    my blog ... asbestos lawyer denver

    ReplyDelete
  8. I do believe all the ideas you have introduced for your post.
    They're very convincing and will definitely work. Nonetheless, the posts are too brief for novices. May you please prolong them a bit from subsequent time? Thank you for the post.

    Here is my website - does zyppah Rx Work

    ReplyDelete
  9. I was suggested this blog by my cousin. I am not sure whether this post is written by way
    of him as nobody else realize such designated approximately
    my problem. You are incredible! Thanks!

    my blog ... guitar lead part play

    ReplyDelete
  10. Howdy! Someone in my Myspace group shared this site
    with us so I came to check it out. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers!
    Excellent blog and wonderful design.

    Also visit my web-site - ps3 linux download

    ReplyDelete