10.设备文件

 1 #include <stdio.h>
 2 #include <unistd.h>
 3 #include <termio.h>
 4 #include <string.h>
 5 
 6 void TestIoflag()
 7 {
 8     struct termio old,new;
 9     char szBuf[100];
10     
11     ioctl(STDIN_FILENO,TCGETA,&old);//获取当前属性
12     
13     new = old;//备份属性
14     
15     //输入到字符大写转小写 更多属性见 2
16     new.c_iflag |= IUCLC;
17     
18     ioctl(STDIN_FILENO,TCSETA,&new);//设置到当前属性
19     
20     scanf("%s",szBuf);
21     
22     printf("szBuf:%s\n",szBuf);
23     
24     ioctl(STDIN_FILENO,TCSETA,&old);//恢复之前的属性
25     
26 }
27 
28 int main()
29 {
30     TestIoflag();
31     return 0;
32 }

1.设备文件操作流程

2.常用属性设置

猜你喜欢

转载自www.cnblogs.com/xiaochi/p/8984033.html
10.