代码拉取完成,页面将自动刷新
#include<stdio.h>
#include<time.h>
#include<sys/stat.h>
#include<unistd.h>
#include<sys/types.h>
#include<errno.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
struct stat buf;
/*检查参数个数*/
if(argc!=2)
{
perror("Usage:my_stat <filename>\n");
exit(1);
}
/*获取文件属性*/
if( stat(argv[1], &buf) ==-1 )
{
perror("stat:");
exit(1);
}
/*打印文件属性*/
printf("设备 %d\n",buf.st_dev);//文件设备编号
printf("文件大小: %d\n",buf.st_size);//文件大小,以字节计算
printf("I/O: %d\n",buf.st_blksize);//文件系统IO缓冲区大小
printf("块个数: %d\n",buf.st_blocks);//占有文件区块个数,一般一个区块大小通常512字节
printf("Inode : %d\n",buf.st_ino);//文件i节点标号
printf("mode: %o\n",buf.st_mode);//文件类型与存取权限
printf("硬链接: %d\n",buf.st_nlink);//硬链接数目
printf("UID : %d\n",buf.st_uid);//用户所有者的用户id
printf("GID: %d\n",buf.st_gid);//用户所有者组id
printf("最近访问: %s",ctime(&buf.st_atime));//文件最近一次被访问时间
printf("最近更改: %s",ctime(&buf.st_mtime));//最后一次被修改的时间
printf("最近改动: %s",ctime(&buf.st_ctime));//最近一次被更改时间
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。