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

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

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

4.c

分类: LINUX

2011-03-05 21:16:16

 

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>
  6. int main(int argc, char *argv[])
  7. {
  8.     int fd;
  9.     int ret;
  10.     if (argc < 2)
  11.     {
  12.         fprintf(stderr, "Usage: %s filename\n", argv[0]);
  13.         return -1;
  14.     }
  15.     fd = open(argv[1], O_RDWR);
  16.     if (fd == -1)
  17.     {
  18.         perror("open");
  19.         return -1;
  20.     }
  21.     ret = lseek(fd, 1 * 1024 * 1024 * 1024, SEEK_END);
  22.     printf("ret = %d\n", ret);
  23.     ret = write(fd, "", 1);
  24.     printf("ret = %d\n", ret);
  25.     close(fd);
  26.     return -1;
  27. }
阅读(1121) | 评论(0) | 转发(0) |
0

上一篇:3.c

下一篇:5.c

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