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

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

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

3.c

分类: LINUX

2011-03-05 21:15:32

  1. #include <stdio.h>
  2. #include <string.h>

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

  6. #include <unistd.h>

  7. #define FILENAME "./test"

  8. enum {
  9.     BUFSIZE = 1024
  10. };

  11. int main(void)
  12. {
  13.     char buf[BUFSIZE] = { 0 };
  14.     int ret;
  15.     int fd;

  16.     fd = open(FILENAME, O_RDONLY);
  17.     printf("fd = %d\n", fd);

  18.     ret = read(fd, buf, BUFSIZE);
  19.     printf("ret = %d\n", ret);
  20.     write(1, buf, strlen(buf));


  21.     return 0;
  22. }
阅读(464) | 评论(0) | 转发(0) |
0

上一篇:2.c

下一篇:4.c

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