c++ - 仅当我在 C++ 中按回车键时代码如何进入下一步(线程)

标签 c++ multithreading while-loop enter

我在网上看到如下代码为

DWORD qThreadID;
HANDLE hThread = CreateThread(0, 0, ThreadFn, &uiCounter, 0, &qThreadID);

// Loop until the user enters 'q'
char cChar = ' ';
while (cChar != 'q') {
    cout << uiCounter << endl;
    cChar = (char)getchar();
}

按键事件“Enter”如何处理它? (当我调试它时,除了按下“Enter”键之外,没有其他按键功能起作用) 谢谢

最佳答案

getchar() 从缓冲的标准输入中读取 库和操作系统中。通常的操作系统不会从读取中返回 控制台设备,直到输入输入;他们支持命令行 编辑,并要求回车键完成输入。

关于c++ - 仅当我在 C++ 中按回车键时代码如何进入下一步(线程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10119144/

相关文章:

c++ - Visual Studio 2013 中的 Windows XP 和 Windows Server 2003 支持

android - 删除线程 Toast 消息

PHP MySQL - while 循环中返回多个选择查询

c - 从 c 中的 .in 文件读取

c++ - 使用 applescript 启动应用程序时,我没有看到启动画面

c++ - std::atomic bool 变量的访问顺序

c++ - MinGW 错误 : ‘thread’ is not a member of ‘std’

windows - 为什么我的 Ruby 线程演示不使用两个内核?

Perl:没有条件的 while

c++ - 如何将 Lambda 表达式与自定义类对象一起使用