Disable line buffer and input echo of stdin

* Disable line buffer and input echo of stdin
*/
static int __getch()
{
char ch;
struct termios old, new;

(void) tcgetattr(STDIN_FILENO, &old);

memcpy(&new, &old, sizeof(struct termios));
new.c_lflag &= ~(ICANON | ECHO);

(void) tcsetattr(STDIN_FILENO, TCSANOW, &new);

ch = getchar();

(void) tcsetattr(STDIN_FILENO, TCSANOW, &old);

return ch;
}

时间: 2024-11-08 04:54:55

Disable line buffer and input echo of stdin的相关文章

input()和sys.stdin.readline()的比较

1.sys.stdin.readline( )会将标准输入全部获取,包括末尾的'\n',input()则不会.一下例子,输入  hello import sys line = sys.stdin.readline() for i in range(len(line)): print(line[i]+'hello') ==> hhelloehellolhellolhelloohello hello 而 import sys line = input() for i in range(len(lin

asm335x系列adc和触摸屏驱动(转)

An analog-to-digital converter (abbreviated ADC) is a device that uses sampling to convert a continuous quantity to a discrete time representation in digital form. The TSC_ADC_SS (Touchscreen_ADC_subsystem) is an 8 channel general purpose ADC, with o

An A-Z Index of the Apple OS X command line

来源:http://ss64.com/osx/ An A-Z Index of the Apple OS X command line alias Create an alias • alloc List used and free memory apropos Search the whatis database for strings asr Apple Software Restore awk Find and Replace text within file(s) b basename

[LINK]php的三种CLI常量:STDIN,STDOUT,STDERR

FROM : http://www.cnblogs.com/thinksasa/archive/2013/02/27/2935158.html PHP CLI(command line interface)中,有三个系统常量,分别是STDIN.STDOUT.STDERR,代表文件句柄. 应用一: <?php while($line = fopen('php://stdin','r')){ echo fgets($line); } ?> 应用二: <?php echo STDIN; ?&g

Muduo 设计与实现之一:Buffer 类的设计

[开源访谈]Muduo 作者陈硕访谈实录 http://www.oschina.net/question/28_61182 开源访谈是开源中国推出的一系列针对国内优秀开源软件作者的访谈,以文字的方式记录并传播.我们希望开源访谈能全面的展现国内开源软件.开源软件作者的现状,着实推动国内开源软件的应用与发展. [嘉宾简介] 陈硕 北京师范大学硕士,擅长 C++ 多线程网络编程和实时分布式系统架构.现任职于香港某跨国金融公司 IT 部门,从事实时外汇交易系统开发.编写了开源 C++ 网络库 muduo

php的三种CLI常量:STDIN,STDOUT,STDERR

PHP CLI(command line interface)中,有三个系统常量,分别是STDIN.STDOUT.STDERR,代表文件句柄. 应用一: <?php while($line = fopen('php://stdin','r')){ echo fgets($line); } ?> 应用二: <?php echo STDIN; ?> 在dos命令行下直接返回STDIN文件指针(文件句柄).如图: 应用三: <?php echo fgets(STDIN); ?>

echo(1)

ECHO(1)                          User Commands                         ECHO(1) NAME echo - display a line of text SYNOPSIS echo [OPTION]... [STRING]... DESCRIPTION Echo the STRING(s) to standard output(标准输出:显示器). -n     do not output the trailing(后面的

关于echo(1)

ECHO(1)                          User Commands                         ECHO(1) NAME        echo - display a line of text SYNOPSIS        echo [OPTION]... [STRING]... DESCRIPTION        Echo the STRING(s) to standard output(标准输出:显示器). -n     do not ou

微信小程序组件解读和分析:十、input输入框

input输入框组件说明: 本文介绍input 输入框的各种参数及特性. input输入框示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 <view class="content"> type:有效值:text 感觉没什么区别 <input  placeholder="type=text" type=