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

📄 popendemo.c

📁 understanding unixlinux source code
💻 C
字号:
/* popendemo.c *	demonstrates how to open a program for standard i/o *	important points: *		1. popen() returns a FILE *, just like fopen() *		2. the FILE * it returns can be read/written *		   with all the standard functions *		3. you need to use pclose() when done */#include	<stdio.h>#include	<stdlib.h>int main(){	FILE	*fp;	char	buf[100];	int	i = 0;	fp = popen( "who|sort", "r" );		/* open the command  */	while ( fgets( buf, 100, fp ) != NULL )	/* read from command */		printf("%3d %s", i++, buf );    /* print data        */	pclose( fp );     			/* IMPORTANT!	     */	return 0;}

⌨️ 快捷键说明

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