开发者

Capture stdin input without echoing characters to screen

I have a very simple code:

char character;    
std::cin >> character;

However, I would like it to behave as follow:

  1. Don't echo to console the character I type
  2. std::开发者_如何学Gocin should return (unblock) right away when a character is pressed without having to press the Enter key

Is this possible? I also have access to Qt.


This is going to be platform dependent, but you can use

getch() which is part of conio.h if you're on windows

or

getch() as part of curses.h if you're on *nix

References

  • http://opengroup.org/onlinepubs/007908799/xcurses/curses.h.html
  • http://en.wikipedia.org/wiki/Conio.h
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜