3 Replies - 20283 Views - Last Post: 24 September 2010 - 10:09 AM Rate Topic: -----

#1 LillianIs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 14-May 10

getche function

Posted 22 September 2010 - 03:36 PM

I am a computer sc student, in the begining of my second year. We just took one course in programming which was c++.
We are begining a new course of data structure and our Doctor gave us a small assignment to search the "getche function", what is it, what is it used for and how to use it ?
so my problem is that I can not find something giving valuable info about the function..
so if you can help me with a link or an article that teach or explain it, that will be great.. but another point I can not do online confrences..

Thats it :)
Thanks
Lillian Is.

Is This A Good Question/Topic? 0
  • +

Replies To: getche function

#2 Seta00  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 84
  • Joined: 22-September 10

Re: getche function

Posted 22 September 2010 - 04:29 PM

getch and getche are functions used to get a single character from the DOS console.
They are not part of the standard, and should not be used.

getch gets a character from standard input and returns it.
getche does the same, but echoes the input character to the standard output.

There isn't a cross-platform solution to getch, but getche can be replaced by

View Postaaa111, on 22 September 2010 - 07:49 AM, said:

cin.ignore(cin.rdbuf()->in_avail()+1);


Just to clarify the previous code:
istream::ignore reads N characters from the input and ignores them.
ios::rdbuf returns the stream buffer associated with the object
streambuf::in_avail returns the amount of characters available for reading

This post has been edited by Seta00: 22 September 2010 - 04:33 PM

Was This Post Helpful? 0
  • +
  • -

#3 LillianIs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 14-May 10

Re: getche function

Posted 24 September 2010 - 09:43 AM

what is the standard that they are not a part of ?
does the standard input means the user's input ?

i am sorry but Ididnt get it very well :(
may u please try and explain it in another way ?

Thanks alot for your help either ways :)
Was This Post Helpful? 0
  • +
  • -

#4 simeesta  Icon User is offline

  • Deadly Ninja


Reputation: 218
  • View blog
  • Posts: 591
  • Joined: 04-August 09

Re: getche function

Posted 24 September 2010 - 10:09 AM

View PostLillianIs, on 24 September 2010 - 05:43 PM, said:

what is the standard that they are not a part of ?
does the standard input means the user's input ?

i am sorry but Ididnt get it very well :(
may u please try and explain it in another way ?

Thanks alot for your help either ways :)


There is a C++ Standard library that contains header files. getche(); is not in these header files, so is not part of the standard.

Yes standard input is the user's input - usually the keyboard.


Some addition info on getch(), getchar() and getche();


getche()
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1