fifo
来源:互联网 发布:蒙古 欧洲 知乎 编辑:程序博客网 时间:2024/04/27 14:21
read data:
/*
* mypipe.c
*
* Created on: 2014-7-30
* Author: root
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <unistd.h>
#include<fcntl.h>
int main()
{
int len = 0;
char buf[100];
memset(buf,0,sizeof(buf));
int fd = open("fifo1",O_RDONLY);
while((len = read(fd,buf,sizeof(buf)))>0)
{
printf("%s",buf);//错误点在此行,如果%s后不加\n,则导致读取数据窗口没有变化,只有等写窗口关闭,读窗口才全部显示出来
}
close(fd);
return 0;
}
writedata:
/*
* writepipe.c
*
* Created on: 2014-7-30
* Author: root
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <unistd.h>
#include<fcntl.h>
int main(int arg,char *args[])
{
int len=0;
char buf[100];
memset(buf,0,sizeof(buf));
int fd = open("fifo1",O_WRONLY);
while(1)
{
scanf("%s",buf);
if(buf[0] == '0')
break;
write(fd,buf,sizeof(buf));
}
close(fd);
return 0;
}
- FIFO
- FIFO
- fifo
- FIFO
- FIFO
- fifo
- FIFO
- FIFO
- fifo
- FIFO
- FIFO
- fifo
- FIFO
- FIFO
- FIFO(转)
- FIFO FIFOs
- IPC FIFO
- FIFO实例
- 关于C++中的虚拟继承的一些总结
- 文件上传漏洞-----图片马的剔除
- Servlet 第六课: Session的使用
- little error
- Choose a destination with a supported architecture in order to run on this device.
- fifo
- 在Emacs中使用etags来浏览代码
- 简记利用ContentProvider执行删除操作
- Failed to create BuildConfig class
- 辛星与您彻底分析PHP中的include和require等的区别
- 小窗口结合能天野好几百
- 小窗合能天野负过荷好
- 规划局看见发动机价格不喝酒
- Eclipse、MyEclipse中的快捷键完全手册,各种注释的快捷键