Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1261760
  • 博文数量: 548
  • 博客积分: 7597
  • 博客等级: 少将
  • 技术积分: 4224
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-15 13:21
个人简介

嵌入式软件工程师&&太极拳

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

7.c

分类: LINUX

2011-03-05 21:21:51

  1. #include <stdio.h>

  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>

  6. #define FILENAME "./test"

  7. int main(void)
  8. {
  9.     int fd;
  10.     int ret;

  11.     fd = open(FILENAME, O_RDWR);
  12.     if (fd == -1)
  13.     {
  14.         perror("open");
  15.         return -1;
  16.     }

  17.     printf("fd = %d\n", fd);

  18.     close(1);
  19.     ret = dup(fd);

  20.     printf("ret = %d\n", ret);

  21.     return 0;
  22. }

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

上一篇:6.c

下一篇:8.c

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