⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig17.27

📁 unix环境高级编程第二版配套源代码 unix环境高级编程第二版配套源代码
💻 27
字号:
#include	"open.h"#include	<fcntl.h>#define	BUFFSIZE	8192intmain(int argc, char *argv[]){	int		n, fd;	char	buf[BUFFSIZE], line[MAXLINE];	/* read filename to cat from stdin */	while (fgets(line, MAXLINE, stdin) != NULL) {		if (line[strlen(line) - 1] == '\n')			line[strlen(line) - 1] = 0; /* replace newline with null */		/* open the file */		if ((fd = csopen(line, O_RDONLY)) < 0)			continue;	/* csopen() prints error from server */		/* and cat to stdout */		while ((n = read(fd, buf, BUFFSIZE)) > 0)			if (write(STDOUT_FILENO, buf, n) != n)				err_sys("write error");		if (n < 0)			err_sys("read error");		close(fd);	}	exit(0);}

⌨️ 快捷键说明

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