如何用C语言显示指定文件信息?包括创建时间,文件大小.和模糊查找文件?像Windows的搜索一样.还是那个程序.

 我来答
tseug8271
2012-06-27 · TA获得超过1499个赞
知道小有建树答主
回答量:745
采纳率:100%
帮助的人:424万
展开全部
#include <stdio.h>
#include <time.h>
#include <io.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
FILE *fp;
struct stat statbuf;
struct ftime ft;
if ((fp = fopen(argv[0],"rb"))!= NULL)
{
fstat(fileno(fp), &statbuf);
/* display the information returned */
if (statbuf.st_mode & S_IFCHR)
printf("Handle refers to a device.\n");
if (statbuf.st_mode & S_IFREG)
printf("Handle refers to an ordinary file.\n");
if (statbuf.st_mode & S_IREAD)
printf("User has read permission on file.\n");
if (statbuf.st_mode & S_IWRITE)
printf("User has write permission on file.\n");

printf("Drive letter of file: %c\n", 'A'+statbuf.st_dev);
printf("Size of file in bytes: %ld\n", statbuf.st_size);
printf("Time file last opened: %s\n", ctime(&statbuf.st_ctime));

getftime(fileno(fp), &ft);
printf("File time: %u:%u:%u\n", ft.ft_hour, ft.ft_min, ft.ft_tsec * 2);
printf("File date: %u/%u/%u\n", ft.ft_month, ft.ft_day, ft.ft_year+1980);
fclose(fp);
}
return 0;
}
来自:求助得到的回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式