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]$ 

  • 相关阅读:
    sync_with_stdio(false)和cin.tie(NULL)
    会场安排问题(贪心 两种方法)
    面向对象分析和设计笔记——第6章界面组件
    用Java实现文件复制
    面向对象分析和设计笔记——第5章输入输出
    面向对象分析和设计笔记——第4章设计模式
    常规类、抽象类和接口的对比分析
    使用for-each循环的三种情况
    StringTokenizer类
    String类的常用方法
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3233699.html
Copyright © 2011-2022 走看看