如何连续读取标准输入? [英] How to read standard input continuously?
本文介绍了如何连续读取标准输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法连续读取标准输入?我想做一个X和O游戏,我想让玩家使用箭头来移动它在网格上的位置。我不能使用 cin
,因为它要求您按Enter键将输入数据转换为变量。
Is there a way to read standard input continuously? I want to make an X and O game and I want the player to use the the arrows to move its position on the grid. I can't use cin
because it requests you to press enter to get the input data into variables. So, does a function or an object doing that exist?
推荐答案
对于控制台(文本)应用程序,你可以使用类似于ncurses
For console (text) applications you'd use something like ncurses, which does terminal 'GUI' controls.
对于图形应用程序,你可以使用像SDL这样的事件驱动编程。
For graphics applications you would use something like SDL which enables event-driven programming.
这篇关于如何连续读取标准输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文