c++编程问题?

Enna 2008-12-03 05:47:28
怎样用c++语言编写一段程序,比较两个文件(包括属性,时间,作者名等等。)是否相同。
...全文
111 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Enna 2008-12-03
  • 打赏
  • 举报
回复
可以用vc的
simplebird 2008-12-03
  • 打赏
  • 举报
回复
vc下可以用 WIN32_FIND_DATA
纯C++的 俺不知道
Enna 2008-12-03
  • 打赏
  • 举报
回复
编写与系统无关的程序,测试两个文件是否相同的程序哦,还是很感谢大家啊!
Enna 2008-12-03
  • 打赏
  • 举报
回复
有稍微简单的吗?
xxgamexx 2008-12-03
  • 打赏
  • 举报
回复

struct stat fileStat;
if(stat("example",&fileStat)==0){
//将文件状态返回到结构fileStat中
cout << fileStat.st_size ;

}else{

};

然后对fileStat结构进行比较!!


The structure stat contains at least the following members:


dev_t st_dev ID of device containing file
ino_t st_ino file serial number
mode_t st_mode mode of file (see below)
nlink_t st_nlink number of links to the file
uid_t st_uid user ID of file
gid_t st_gid group ID of file
dev_t st_rdev device ID (if file is character or block special)
off_t st_size file size in bytes (if file is a regular file)
time_t st_atime time of last access
time_t st_mtime time of last data modification
time_t st_ctime time of last status change
blksize_t st_blksize a filesystem-specific preferred I/O block size for
this object. In some filesystem types, this may
vary from file to file
blkcnt_t st_blocks number of blocks allocated for this object
zhqyzhqychn 2008-12-03
  • 打赏
  • 举报
回复
这个得用到系统调用吧,取决于你的系统是什么,例如unix/linux 可以用stat或fstat //#include<sys/stat.h>

70,038

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧