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

📄 rp2.c

📁 linux 下模拟shell的实现。 支持管道等功能。读proc文件
💻 C
字号:
/*This program realize the function that recive a filename from standard input device, * read the file and output the content by standard output device. *  * you must compeletly realize by systemcall ,and can't use libery function and parameters by main! * * Kong Xiangzhen  * class 33 * 03055078 * OCT 27th ,2006.*/ #include <unistd.h>#include <stdio.h>#include <sys/types.h>#include <fcntl.h>#include <sys/stat.h>#define max_read_size 2000#define max_filename 100int main(){	int fd,i_r,i_w;	char buff[max_read_size];	char tip[100]="Give the file's name that you want to read:";	char readfilename[max_filename];        	if((i_w=write(1,tip,100))<0)	{		perror("write tip error!");		exit(0);	}	if((i_r=read(0,readfilename,sizeof(readfilename)))<0)	{		perror("read filename error!");		exit(0);	}	readfilename[i_r-1]='\0';	if((fd=open(readfilename,O_RDONLY,0644))<0)	{		perror("open error!");		exit(0);	}	if((i_r=read(fd,buff,sizeof(buff)))<0)	{		perror("read error!");		exit(0);	}	if((i_w=write(1,buff,i_r))<0)	{		perror("write error!");		exit(0);	}	return 0;}		

⌨️ 快捷键说明

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