Chinaunix首页 | 论坛 | 博客
  • 博客访问: 119359
  • 博文数量: 41
  • 博客积分: 1695
  • 博客等级: 上尉
  • 技术积分: 430
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-21 22:50
文章分类

全部博文(41)

文章存档

2010年(1)

2007年(23)

2006年(17)

我的朋友

分类: C/C++

2007-01-19 22:55:26

#include
#include
#include
#include
#include

int main(int argc, char *argv[])
{
        char buf[BUFSIZ];
        int f1, n;
        if(argc == 1)
                while((n = read(0, buf, sizeof buf)) > 0)
                        write(1, buf, n);
        else
        {
                while(--argc>0)
                        if( ( f1=open(*++argv, O_RDONLY, 0) ) == -1)
                                printf("cat: can't open file \"%s\"!\n", *argv);
                        else
                                while( ( n = read(f1, buf, BUFSIZ) ) >0)
                                        write(1, buf, n);
        }
        return 0;
}

阅读(1105) | 评论(0) | 转发(0) |
0

上一篇:图的创建

下一篇:read, write, lseek 练笔

给主人留下些什么吧!~~