program5.c

来自「内含6个Linux平台下的程序」· C语言 代码 · 共 59 行

C
59
字号
/*#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>

main()
{
int fd;
int n;
int fdnum;
char buf[256];
mknod("fifo",S_IFIFO|0666,0);
fd = open("fifo",O_WRONLY);
fdnum = open("mywork",O_RDONLY);
//while((n=read(fdnum,buf,256))>0)
while(gets(buf)!=NULL)
{
write(fd,buf,256);
}
close(fd);
}*/




















#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>

main()
{
int fd;
char buf[256];
mknod("fifo",S_IFIFO|0666,0);
fd = open("fifo",O_WRONLY);
while(gets(buf)!=NULL)
{
write(fd,buf,strlen(buf)+1);
}
close(fd);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?