If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Originally posted here by cgkanchi AFAIK, getch() and getche() aren't ANSI C functions. Therefore, you are not guaranteed that they will work. I know for a fact that it doesn't work on gcc and that it works on Turbo/Borland C++.

getch() and getche() (and some other console functions) are included in conio.h. But yes, they aren't ANSI C functions. And conio.h doesn't come with (original) gcc. However, MinGW port of gcc (and Dev-CPP and cygwin's gcc which uses MinGW) does have conio.h header file.

So if you have C code which uses getch() or getche() that works on Turbo/Borland C++ or VC++, just do #include &lt;conio.h&gt;, and it will work on MinGW and Dev-CPP.

Peace always,&lt;jdenny&gt;

Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert HeinleinI\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds

So if you have C code which uses getch() or getche() that works on Turbo/Borland C++ or VC++, just do #include &lt;conio.h&gt;, and it will work on MinGW and Dev-CPP.

Same is the case is with Turbo C++ ...you will have to #inclue &lt;conio.h&gt; to get them working.. ...So what is the difference..sorry for my ignorance...the only C/C++ Compilers i have used are Turbo, Borland and Visul C++....

all of the above replies makes sense but i have got the real reason why this isn't working! this is because u must be using Browland C++ 3.0 version of turbo c++, the compiler of this version is that the compiler gives problems sometimes for scanning the value with scanf().
what u have to do is to get a C compiler which will definitely work! i m sure about this!

Yes Trubo C++ will always give you this problem of not scanning the character variable if used just after some other variable in this faschion......it will just ignore it and go to the next statement .........it would have scaned the same value if it would have been the first value you have scanned .....i have no idea why.......apart from changing the compiler.......more simple solution i think is to use string %s it solves this problem...or specify the index number ch[0] where to store the value......that solves this problem........I had encountered this problem in the very early days of my learning C and at that time it got me soooo pissed ........because i just couldn't make out what the problem was ..........so so now that he has brought up the issue i would too like to know the reason if anybody knows........

If a few people didn't understand what akshayakrsh and i am trying to say here is look at the following code

In the following code it wouldn't even wait for me to put in the character value ....just after putting the number and pressing enter it would show the result wouldn't wait at the character............and the strange thing is i don't find anything wrong with this code........

If i input the number after the character it would work fine.......as in the following code

And one thing more akshayakrsh........Some.People here generally don't appriciate bumping of very old threads until you have something useful to add......which i think you had here..........the thing is it is considered that if the thread is soo old the problem might have been solved by now.......If you have to post to a very old thread to add something to it.......... the Golden rule to Bump the thread first and then post ........keeps tham wondering ...........just a word of advice i know this thread is not that old .

And i would like to suggest you would want to remove your Complete address from the location.....because you got the whole thing there with house Number With Pin Code......this being a public site you never know we got quite a few stakers around here j/k.........or are you Expecting Fan-mails