getch,getchar,scanf ...不要在多线程控制台应用程序中返回 [英] getch, getchar, scanf ... do not return in multi threaded console application

查看:357
本文介绍了getch,getchar,scanf ...不要在多线程控制台应用程序中返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个Windows控制台应用程序.该应用程序创建了两个附加线程.

然后,我必须检查按键.我尝试用getch,getchar,_getch_nolock,scanf,...
来做到这一点 当我从另一台计算机(从另一台计算机)远程调试该应用程序时(F10),调用
getch永远不会回来.即使按了几个键.

按下某些键可为计算机提供输入.因此,getch应该按第一个按键返回.
但是它不会返回.使用getchar,scanf,...进行相同的操作会得到相同的结果:它们也一样
不回来.




Hi,

I have a Windows console application. This application creates two additional threads.

Then I have to check for a key press. I tried to do this with getch, getchar, _getch_nolock, scanf, ...
When I remotely (from another computer) debug this application step by step (F10), a call to
getch does never return. Even when I press several keys.

Pressing some keys feeds the computer with input. Therefore getch should return with the first pressed key.
But it does not return. Trying the same with getchar, scanf, ... leads to the same result: they also do
not return.


How can this problem be solved?

推荐答案

2012年1月1日上午7:36,ThePerfectWave写道:

On 10/1/2012 7:36 AM, ThePerfectWave wrote:

然后我必须检查按键.我尝试用getch,getchar,_getch_nolock,scanf,...
来做到这一点 当我从另一台计算机远程(从另一台计算机)调试该应用程序(F10)时,调用
getch永远不会回来.即使按了几个键.

Then I have to check for a key press. I tried to do this with getch, getchar, _getch_nolock, scanf, ...
When I remotely (from another computer) debug this application step by step (F10), a call to
getch does never return. Even when I press several keys.

是否输入这些键之一? CRT通常会缓冲控制台输入,直到按下Enter键为止.

Is Enter one of those keys? CRT generally buffers console input until Enter is pressed.


这篇关于getch,getchar,scanf ...不要在多线程控制台应用程序中返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆