您的位置:首页 > 运维架构 > Linux

linux之stat函数解析

2013-08-02 12:19 330 查看
[lingyun@localhost stat_1]$ vim stat.c

 + stat.c                                                                                                                    

/*********************************************************************************

 *      Copyright:  (C) 2013 fulinux<fulinux@sina.com> 

 *                  All rights reserved.

 *

 *       Filename:  stat.c

 *    Description:  This file 

 *                 

 *        Version:  1.0.0(08/02/2013~)

 *         Author:  fulinux <fulinux@sina.com>

 *      ChangeLog:  1, Release initial version on "08/02/2013 12:15:08 PM"

 *                 

 ********************************************************************************/

#include <sys/stat.h>

#include <unistd.h>

#include <stdio.h>

int main(void)

{

    struct stat buf;

    stat("/etc/hosts", &buf);

    printf("/etc/hosts file size = %d\n", buf.st_size);

}

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

 ~/apue/stat/stat_1/stat.c[+]   CWD: /usr/local/src/lingyun/apue/stat/stat_1   Line: 22/23:55                                

"stat.c" [New] 23L, 714C written

[lingyun@localhost stat_1]$ ls

stat.c

[lingyun@localhost stat_1]$ gcc stat.c 

[lingyun@localhost stat_1]$ ./a.out 

/etc/hosts file size = 83

[lingyun@localhost stat_1]$ 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: