![]() |
| | #1 |
| Registered User Join Date: Oct 2006
Posts: 298
| equivalent to getch in c++ well, you're almost right. Am I the only one who thinks it is a pretty big oversight not to have the ability to read a single character from an std::istream, without waiting for a delimiter? seriously, how hard would it be to add a function which, when called, it would sit and wait until there was at least one character available in the input buffer and then it would remove that character from the buffer and immediately return its value, regardless of whether a delimiter was encountered. I really don't understand why it is not a part of the standard library. it would be such a useful function to have, and would certainly see more use than many other features of the c++ standard library. just looking for thoughts/opinions on this. |
| Elkvis is offline | |
| | #2 |
| Registered User Join Date: Jan 2005
Posts: 7,252
| The problem is that standard C++ knows nothing of the "console" it is reading from. Not all consoles will be able to send characters immediately. And note that it isn't waiting for the delimiter. The console you use provides the data for the application after <enter> is pressed, regardless of what delimiter you specify. That's just how your console works. The solution is to have a non-standard method that does exactly what you ask and works on the consoles that allow for it. That is what getch() is, and that is why there is no new solution. The only thing the standard could do is add an interface that could be implemented with getch() on platforms that support that type of behavior, but I'm not sure that's really necessary when getch() will suffice. |
| Daved is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| getch() equivalent in C++ | hauzer | C++ Programming | 3 | 06-02-2009 05:54 PM |
| Another syntax error | caldeira | C Programming | 31 | 09-05-2008 01:01 AM |
| kbhit() and getch() Equivalent.. | ThLstN | C Programming | 1 | 03-11-2008 02:44 AM |
| Pls repair my basketball program | death_messiah12 | C++ Programming | 10 | 12-11-2006 05:15 AM |
| FAQ: Is there a getch() (from conio) equivalent on Linux/UNIX? | kermi3 | FAQ Board | 0 | 11-01-2002 11:56 AM |