Pages

Wednesday, July 13, 2011

The getch() Function in C and C++

Function Name: getch()   
Function Header: <conio.h>
Declaration: int getch(void)
Return Value: This function returns the character read from the keyboard.
 
The getch() function is used to catch a character from the keyboard. The getch() function reads a single character from the keyboard but does not show on the screen. For this functionality, you can use the getch() function to hold the output window until hitting any key from the keyboard.


Example of the getch() function

#include <conio.h>
#include <stdio.h>

void  main()
{
  int c;
  printf(“Press any key\n”);
  c = getch();
  if (c)
    printf(“A key is pressed from keyboard ”);
  else
   printf(“An error occurred ”);
  getch()
}


Output

26 comments:

Rabina said...

Nice information...........

srikanth said...

thanxxxx 4 infooo

Anonymous said...

It's very easy to find out any matter on web as compared to textbooks, as I found this article at this web site.
Here is my blog post :: free ps3 games

Anonymous said...

Pretty nice post. I simply stumbled upon your weblog and wished to mention that I have really loved surfing around your
blog posts. After all I will be subscribing for your feed and I'm hoping you write once more very soon!

Here is my blog; best registry cleaner

Anonymous said...

Aw, this was a really good post. Taking a few minutes and actual effort to make a great article… but what can
I say… I hesitate a lot and don't seem to get nearly anything done.

Here is my webpage: http://www.super-motores.com.radabg.com/url/curved-shower-rod-col8o464fo.modwedding.com
Also see my website :: bathroom cabinet

Anonymous said...

What's up to every , as I am in fact keen of reading this blog's post to be updated on a regular basis.
It carries nice data.

my page - bathroom remodel ideas

Anonymous said...

For hottest news you have to visit web and on web I found this
web site as a most excellent web site for most up-to-date updates.


Check out my blog ... know more

Anonymous said...

Βе cаutіοus ωith washing sodа and use gloves aѕ it іs reallу
alkаlіne. These ѕubѕtanсeѕ aге often expеrienсed in all sorts οf rеsіԁences, evеn individuals that аге not mеаnt to be 'green'.
A full grain breaκfaѕt of аgеd-fаѕhioneԁ оаtmeal ωith almonds (gгind them uр to coveг
thеm, if cгіtісal) will
mаіntain a сhilԁ waу fοr
a longеr tіme than orangе juice аnd a bagel.


my web рagе - pizza stone chester vt hours

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Hello, I enjoy reading through your article post.
I like to write a little comment to support you.

Also visit my site ... waist to height ratio chart

Anonymous said...

Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You definitely know what youre talking about, why throw away your
intelligence on just posting videos to your site when
you could be giving us something informative to read?

my web page - Juegos Online Gratis

Anonymous said...

What's up friends, its enormous paragraph concerning cultureand completely defined, keep it up all the time.

Also visit my website jocu cu inpuscaturi

Anonymous said...

Hello every one, here every one is sharing
these know-how, so it's good to read this blog, and I used to pay a quick visit this website everyday.

Here is my webpage - jocuri cu table online

Unknown said...

thax

Unknown said...

thax

Unknown said...

thax

Unknown said...

If i am going to enter 0 from keyboard then it will print An error occurred.....because in c/c++ the if condition works on 0/1.

Anonymous said...

Hello, i think that i noticed you visitеd my blog
thus i саme to return thе chοose?
.I'm trying to find things to improve my site!I suppose its good enough to use some of your ideas!!China ccc ()

Reuven said...

Very good information - both brief and fully descriptive.

younger idea said...

Get easy Free Hindi Ebooks of Programming Languages PHP,JAVA, HTML5 and CSS3,JAVASCRIPT,JQUERY,C,C++,C#(SHARP),DATA STRUCTURE,VB6 etc.

Get,Learn & Do & Earn Huge Income.
For get the ebooks free in pdf format,click on below link:

Free Downloads Ebooks of Programming Languages in Hindi in pdf format

younger idea said...

Get easy Free Hindi Ebooks of Programming Languages PHP,JAVA, HTML5 and CSS3,JAVASCRIPT,JQUERY,C,C++,C#(SHARP),DATA STRUCTURE,VB6 etc.

Get,Learn & Do & Earn Huge Income.
For get the ebooks free in pdf format,click on below link:

Free Downloads Ebooks of Programming Languages in Hindi in pdf format

younger idea said...

test 12Get easy Free Hindi Ebooks of Programming Languages PHP,JAVA, HTML5 and CSS3,JAVASCRIPT,JQUERY,C,C++,C#(SHARP),DATA STRUCTURE,VB6 etc.

Get,Learn & Do & Earn Huge Income.
For get the ebooks free in pdf format,click on below link:

Free Downloads Ebooks of Programming Languages in Hindi in pdf format

younger idea said...

Now Prgramming is very easy for everyone. So Learn Programming In Very Easy Way In HINDI Language.

Get Free Hindi Ebooks of Programming Languages PHP,JAVA, HTML5 and CSS3,JAVASCRIPT,JQUERY,C,C++,C#(SHARP),DATA STRUCTURE,VB6 etc. in pdf format.

For get all these ebooks free in pdf format,click on below link:

Free Downloads Ebooks of Programming Languages in Hindi in pdf format

tapi said...

@Engg. true that C is case sensitive language, but the preprosessor (directives starting with#) is not a part of C language. Furthermore, CONIO.H dates from MS-DOS times, when the 8.3 filenames were all uppercase, so UC is definitely correct, even though the preprocessor allows for lowercase.

Anonymous said...

I have problem with unicode UTF-8 characters and getch
say hebrew ‎...
דבא
I see only question mark... :-(
jk

Yodi said...

Thanks! nice tutorial