stat函数_linux 系统调用stat函数

e2fc689a07885793871a356453fe6b2c.png
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

struct stat file_stat;

void print_file_stat(struct stat *fs)
{
    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>n");
    printf("inode: tttt%ldn", fs->st_ino);
    printf("protection: ttt%on", fs->st_mode);
    printf("number of hard links: tt%lun", fs->st_nlink);
    printf("user ID of owner: tt%dn", fs->st_uid);
    printf("group ID of owner: tt%dn", fs->st_gid);
    printf("file size in bytes: tt%ldn", fs->st_size);
    printf("time of last access: tt%s", ctime(&fs->st_atime));
    printf("time of last modification: t%s", ctime(&fs->st_mtime));
    printf("time of last change: tt%s", ctime(&fs->st_ctime));
}   

int main(int argc, char* argv[])
{   

    if (2 != argc) {
        fprintf(stderr, "Usage: %s filename...n", argv[0]);
        exit(-1);
    }

    if (0 != stat(argv[1], &file_stat)) {
        perror("stat"); 
        exit(-1);
    }

    print_file_stat(&file_stat);

    return 0;
}   
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页