search

Home  >  Q&A  >  body text

如何做到即时地读入信息?[C++即可]

我遇到的问题是这样的:
平时我们scanf("%d",&tee);必须要回车啊之类的空白符确认才行
那有没有像chrome搜索栏(或者baidu……)那样的即输(入)即得?
不需要按回车就能读入应该如何实现?

谢谢:)

PHP中文网PHP中文网2768 days ago590

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:46:14

    This may help you
    http://stackoverflow.com/questions/421860/capture-characters-from-standard-input-without-waiting-for-enter-to-be-pressed

    PS: If you encounter technical problems, try using Google and stackoverflow, :)

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:46:14

    scanf is obviously not suitable for this. This is to determine whether the input is completed based on the user's input and press Enter. The two you mentioned are in GUI mode. I suggest you look at the Windows API or some packaged APIs, so Hook each input of the user. For example, if the user expects to input "C++ programming", the user will input "C", "+", "+", "program", and "program" in sequence. The characters you intercepted Then put it in the background for processing, and then put it in the display interface for display.

    reply
    0
  • Cancelreply