如何同步运行两个语法命令?

时间:2017-07-18 18:09:25

标签: c++ multithreading

我如何实施"多任务处理"在C ++中?

1 个答案:

答案 0 :(得分:1)

对于终端中的Pong风格游戏,您需要使用ncurses库。在那里,你可以写一个类似这样的游戏循环

#include <curses.h>

while (true) {
    int k = getch();
    // Determine whether k is a keypress or not, and take action if so.
    // Update game display
}

getch()功能可以检查键盘输入而无需停下来等待它。