Ash*_*ish 11 c c++ linux
我想在linux OS上找到磁盘上文件的大小.我知道这样做的命令:du -s -h
有没有办法使用c/c ++代码找到它?
Bla*_*iev 17
是的,使用stat(2)系统调用:
stat(2)
#include <sys/stat.h> ... struct stat statbuf; if (stat("file.dat", &statbuf) == -1) { /* check the value of errno */ } printf("%9jd", (intmax_t) statbuf.st_size);
归档时间:
14 年,10 月 前
查看次数:
15234 次
最近记录: