C了解标准输入缓冲区之前它提交 [英] C read stdin buffer before it is submit
问题描述
这可能是因为我还没有发现这种行为记录任何地方,但很好奇,如果任何人有任何技巧来完成这样的事情如此情况下是不可能的。是否有可能来确定标准输入缓冲区的内容,程序之前,用户实际命中输入提交的数据?
It is likely that this type of scenario is not possible as I have not found this behavior documented anywhere but was curious if anyone had any tricks to accomplish something like this. Is it possible to determine the contents of the stdin buffer for a program before the user actually hits enter to submit the data?
我试图做到这一点,因为我已经建立它发送消息从一个终端到另一个容易沟通一个简单的终端聊天程序。我们所遇到的问题是,由于传入消息和传出消息出现在终端在一起,如果用户打字时从它扭曲了显示器的另一端收到一条消息,在刚刚结束追加输入消息的消息收到的消息。这将是方便,如果有检查缓冲区的内容,并采取相应的行动方式,但我不知道这是可能没有GUI接口类型级别。
I am attempting to do this as I have built a simple terminal chat program which sends messages from one terminal to another for easy communication. The issue we have run into is that since incoming messages and outgoing messages appear in the terminal together, if a user is typing a message when a message is received from the other end it distorts the display and appends the typed message at the end of newly received message. It would be convenient if there was a way to check the contents of the buffer and act accordingly, but I am not sure if this is possible without a gui type interface level.
推荐答案
搜索此页面上的kbhit.c:的 http://pwilson.net/sample.html
Search for 'kbhit.c' on this page: http://pwilson.net/sample.html
这篇关于C了解标准输入缓冲区之前它提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!