What should I use instead of _putche() in my codes. There is really no replacement for this?
What should I use instead of _putche() in my codes. There is really no replacement for this?
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
_putche is from what library?
If there is no standard alternative, then you just have to use non-standard code. In your release of the source, you'll have to say what libraries you used. It's not uncommon and it's not that bad. There is no real standard APIs and no standard conio functions, but people use them when they're necessary.
If, by chance, you know how to replicate it using standard library functions, then you could try to do that. It will make it much easier, as you can distribute it with your release.
Sent from my iPadŽ
[edit]_putche is from what library?
I mean _getche() [edit] and it gives you a warning if you use getche().
Isn't it strange that C/C++ doesn't have a standard function for reading one key from keyboard buffer? Now I have to use getche().Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getche. See online help for details.'
Last edited by siavoshkc; 08-13-2006 at 05:29 PM.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
It's not so strange when you think about the reason why C++ doesn't have a standard function for reading from the keyboard buffer. The problem is that concepts such as keyboard buffers are entirely system specific, so there is no way that the C++ standard could possibly cater for it. much in the same way that C++ doesn't cater for mouse input or graphical functions.
using non-standard and non-portable code isn't a bad thing, in fact, it's usually not possible, or desirable, to stick 100% to the standard C++ language for any (useful) real-world application, just that, as a user of the libraries, you'll usually find far less support around than for the standard language (Except perhaps Boost and some MS libraries), hence why beginners are generally discouraged from diving into them before being comfortable with the language first
Last edited by Bench82; 08-13-2006 at 06:15 PM.
I'm not sure if we are talking about _putche() or _getche() here.
_getche() is Visual C++ 2005 replacement for getche().
_putche() doesn't exist anywhere in MSDN documentation. There exists _putch() which is the replacement function for putch(). But no _putche(). Since the difference between _getch and _getche is simply the fact the character will be or not echoed to the screen, I can't seem to find a reason for a _puthche() function. What would be the purpose of writting a character to the console without echoing it?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
http://msdn2.microsoft.com/en-us/library/azb6c04e.aspx
Referring to _putch and _putwchThese functions write the character c directly, without buffering, to the console.
You can define getch to _getch[e] if you are on a non-POSIX (Windows) system and have conio, or otherwise have curses. Or use something like pdcurses.
There's putchar() and getchar(), which work with stdout and stdin respectively. They do what you say "reading [or write] one key from keyboard buffer".
Edit: But if your using c++ it's better to do "cin >> mychar" and "cout << mychar".
_getch(), _getche() and _putch() are unbuffered.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
It exists only in this thread, it is my typing mistake. I mixed getche() and putch() together!!!_putche() doesn't exist anywhere in MSDN documentation.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C