📄 tube_test.c
字号:
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>int main(){ int fd; int c; char buf[2]; fd=open("/dev/tube/0",O_RDWR); if(fd < 0){ printf("####DEMO device open fail####\n"); return (-1); } while(1) { while(1) { fputs("Please input an integer between 0-99, number 0 will quit: ", stdout); if ( scanf("%d", &buf[0]) != EOF ) { while ( (c=getchar()) != '\n' && c != EOF ) { ; } /* end of while */ } if(buf[0]==0) break; // quit if(buf[0]>99 || buf[0]<0) { printf("Please input the number between 0-99\n"); } else { break; } } if(buf[0]==0) break; printf("what you want to show is: %d\n", buf[0]); write(fd,&buf[0],sizeof(char)); // printf("if you want to quit ,please input q "); // if (getchar() =='q' ||getchar()=='Q') break; // sleep(1); } close(fd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -