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

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

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

1.c

分类: LINUX

2011-03-05 21:11:55

  1. #include <stdio.h>

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

  6. #include <errno.h>

  7. #define FILENAME "./test"

  8. #define FLAGS (O_RDWR | O_CREAT)

  9. #define MODE (S_IRUSR)

  10. int main(void)
  11. {
  12.     int fd;

  13.     fd = open(FILENAME, FLAGS, MODE, 1, 2, 3, 4, 5);
  14.     printf("fd = %d\n", fd);
  15.     if (fd == -1)
  16.     {
  17.         printf("errno = %d, ENOENT = %d\n", errno, ENOENT);
  18.         perror("open");
  19.         return -1;
  20.     }

  21.     close(fd);

  22.     return 0;
  23. }
阅读(547) | 评论(0) | 转发(0) |
0

上一篇:汇编基础

下一篇:2.c

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