tube_test.c
来自「数码管驱动以及检测文件,S3C2410Linux」· C语言 代码 · 共 68 行
C
68 行
#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 + =
减小字号Ctrl + -
显示快捷键?