文件的操作
来源:互联网 发布:纽约房价 知乎 编辑:程序博客网 时间:2024/05/21 10:29
本程序 旨在把argv[1]中的内容写入myfifo中
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define FIFO_SERVER "/home/wangjian/wangjian/jctx/myfifo"
- int main(int argc,char* argv[])
- {
- int fd, i = 0;
- char w_buf[100];
- int nwrite;
- FILE *p;
- fd=open(FIFO_SERVER,O_WRONLY|O_NONBLOCK|O_CREAT,0);
- if(fd==-1)
- if(errno==ENXIO)
- printf("open error; no reading process/n");
- else
- printf("other error [%d]/n",errno);
- if(argc==1)
- {
- printf("Please send something/n");
- exit(0);
- }
- if ((p = fopen(*++argv, "r")) == NULL)
- printf("error open argv[1]");
- while ((w_buf[i++] = getc(p)) != EOF)
- ;
- w_buf[i] = '/0';
- //strcpy(w_buf,p);
- //strcpy(w_buf,argv[1]);
- printf("w_buf : %s/n", w_buf);
- if((nwrite=write(fd,w_buf,strlen(w_buf)))==-1)
- {
- if(errno==EAGAIN)//资源暂时不可用
- printf("The FIFO has not been read yet.Please try later/n");
- else
- printf("other error [%d]/n",errno);
- }
- else
- printf("write %s to the FIFO/n",w_buf);
- exit(0);
- }
- 文件操作文件的读入
- 文件操作文件的读入
- 文件与文件的操作
- 文件的操作
- 文件、文件夹的操作
- 对文件的操作
- CBuilder的文件操作
- 简单的文件操作
- 对文件的操作
- C的文件操作
- Javascript的文件操作
- 文件的相关操作
- ACE的文件操作
- ACE 的文件操作
- VB6的文件操作
- C的文件操作
- 文件操作的函数
- 文件的一些操作
- 数据结构的学习方法
- 时间..
- 刚开通的。。。
- 常量const
- php表单
- 文件的操作
- 偶尔示弱又何妨
- CDSN学习的家园
- 8月26日JAVA笔记
- 能力与素质
- RSS简单阅读器(.net)
- 让.net站点拥有RSS功能
- PageDataSoure实现分页(转)
- svn学习心得