Linux 下getch()和getche()

2 篇文章 0 订阅

Linux下getch()和getche()



I would recommend never mixing input techniques in a program. Don't mix fgets() or scanf() with getchar(). Don't mix any standerd C library input function with a non-standard function that bypasses the C stream mechanism, be that getch(), getche(), bioskey(), or anything else. Note that these functions do not read from stdin, they read from a hardware keyboard, which is not the same thing.


 

 

 


Functions like getch() and getche() haven't been incorporated into the C standard because not all host systems provide ways to turn off input buffering. Thus compilers include these as common extensions wherever possible.


 

 

 

 


It is worth pointing out that writing Standart C (or Standart POSIX or whatever) is not always useful or desirable. It is up to the programmer to decide when and whether the benefits of sticking to any particular standards are worth their costs. But in order to make such a decision (and execute it), information *about* those standards is very important.


 

 

 



希望大家能够写出自己的getch() or getche()。


 

 

 



以上是在网站http://bytes.com上的摘录,链接为http://bytes.com/topic/c/answers/476130-getch-getche

 


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值