打印用户键入的每个字符,不带conio.h

问题描述 投票:-1回答:1

我想制作一个永远运行的程序并接受用户输入,例如

while(1)
{  
    if(currentkeybeingpressed != NULL)
    {
        print(the current character); /* So that the program just waits until a key is 
                        pressed and outputs the same letter the moment it is touched*/
    }
}

我想在KISS控制器上执行此操作,该控制器没有准备好导入的conio.h文件,因此我无法使用getch函数。还有另一种方法可以找出目前正在按下的键吗?

c
1个回答
0
投票
#include<stdio.h>

int main() {
   while(1){
       putchar(getchar());
   }
}

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.