Linux的输入和删除的

一,tcgetattr和tcsetattr的使用方法

#include <termios.h>
       #include <unistd.h>

       int tcgetattr(int fd, struct termios *termios_p);

       int tcsetattr(int fd, int optional_actions,
                     const struct termios *termios_p);

       int tcsendbreak(int fd, int duration);

       int tcdrain(int fd);

       int tcflush(int fd, int queue_selector);

       int tcflow(int fd, int action);

       void cfmakeraw(struct termios *termios_p);

       speed_t cfgetispeed(const struct termios *termios_p);

代码

#include <stdio.h>                                                                  
  2 #include <stdlib.h>
  3 #include <unistd.h>
  4 #include <string.h>
  5 #include <termios.h>
  6 #include <errno.h>
  7 
  8 
  9 int main(void)
 10 {
 11 
 12 
 13     struct termios term;
 14 
 15     if ( tcgetattr(STDIN_FILENO, &term) == -1 )  //通过
 16     {
 17         printf("tcgetattr error is \n"/*, strerror(errno)*/);
 18         return -1;
 19     }
 20 
 21     term.c_cc[VERASE] = '\b';   //这个代表前面字符的功能
 22     //term.c_cc[VINTR]; //这个代表进程送一个SIGINT信号键
 23 
 24     if ( tcsetattr(STDIN_FILENO, TCSANOW,  &term) == -1)
  {
 26         printf("tcsetattr error is %s\r\n", strerror(errno));
 27         return -1;
 28     }
 29 
 30 
 31     char buf[1024];
 32     memset(buf, 0, sizeof(buf));
 33 
 34     read(STDIN_FILENO, buf, sizeof(buf));
 35 
 36     return 0;
 37 }    

linux的输入删除的使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值