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

📄 write0.c

📁 unix linux 编程实践源代码
💻 C
字号:
/* write0.c * *	purpose: send messages to another terminal *	 method: open the other terminal for output then *	 	 copy from stdin to that terminal *	  shows: a terminal is just a file supporting regular i/o *	  usage: write0 ttyname */#include	<stdio.h>#include	<fcntl.h>main( int ac, char *av[] ){	int	fd;	char	buf[BUFSIZ];	/* check args */	if ( ac != 2 ){		fprintf(stderr,"usage: write0 ttyname\n");		exit(1);	}	/* open devices */	fd = open( av[1], O_WRONLY );	if ( fd == -1 ){		perror(av[1]); exit(1);	}	/* loop until EOF on input */	while( fgets(buf, BUFSIZ, stdin) != NULL )		if ( write(fd, buf, strlen(buf)) == -1 )			break;	close( fd );}

⌨️ 快捷键说明

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