zoukankan      html  css  js  c++  java
  • linux之stat函数解析

    [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 ", 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]$ 

  • 相关阅读:
    (转)卡特兰数
    fatal error LNK1123: 转换到 COFF 期间失败
    cocos2dx 中文乱码问题
    c++ primer查漏补缺(一)命名空间
    Centos 7 二进制部署高可用Kubernetes v1.17.x
    hostAliases给pod增加域名解析
    常用的清理 Kubernetes 集群资源命令
    Kubernets 污点与容忍
    Docker 常用命令大全
    Kubernets健康检查——配置存活、就绪和启动探测器
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3233699.html
Copyright © 2011-2022 走看看