fifo02.c
来自「嵌入式Linux程序设计与应用案例 电子书源码 中国电力出版社」· C语言 代码 · 共 29 行
C
29 行
/***********
// name : fifo02.c
// author : pyy
// date : 2007-11-23
***************/
#include<sys/types.h>
#include<sys/stat.h>
#include<errno.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<limits.h>
#include<fcntl.h>
int main( void )
{
int fd;
int len;
char buf[PIPE_BUF];
/* 打开名为test 的 FIFO */
fd = open("test",O_RDONLY);
if(fd < 0) {perror("open error"); exit(1);}
/* 读取 FIFO 存入buf变量中 */
while((len = read(fd, buf ,PIPE_BUF-1))>0) printf("%s",buf);
close(fd);
exit(0);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?