Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4188025
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类: LINUX

2010-12-24 15:11:33

/*
 * fstat(由文件描述词取得文件状态)
 * 相关函数  stat,lstat,chmod,chown,readlink,utime
 * 表头文件
 * #include
 * #include
 * 定义函数
 * int fstat(int fildes,struct stat *buf);
 * 函数说明  fstat()用来将参数fildes所指的文件状态,复制到参数buf所指的结构中(struct stat)。
 * Fstat()与stat()作用完全相同,不同处在于传入的参数为已打开的文件描述词.
 * 返回值  执行成功则返回0,失败返回-1,错误代码存于errno。
 */
 
/* 范例 */
#include
#include
#include
#include
#include
#include
 
main()
{
    struct stat buf;
    int fd;
    fd = open ( "/etc/passwd", O_RDONLY );
    fstat ( fd, &buf );
    printf ( "/etc/passwd file size: %d\n", buf.st_size );
}
 
/* 执行  /etc/passwd file size = 705 */
阅读(1789) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~