11 2011 档案

摘要:cat命令简单实现cat工具实现起来比较简单,下面代码采用基本的open、read、printf、close函数,基本可以实现cat命令的功能: 1 #include <stdio.h> 2 #include <unistd.h> 3 #include <fcntl.h> 4 5 #define READSIZE 4096 6 7 int main(int ac, char* av[]){ 8 int rfd=-1,rlen=-1,ret=-1; //被文件描述符、读取内容长度、程序返回值 9 char rbuf[READSIZE]; //读取内容缓冲1.. 阅读全文
posted @ 2011-11-03 16:20 李意锋 阅读(616) 评论(0) 推荐(1)