time是指从1970年1月一日到本地时刻的秒数

#include <iostream>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

using namespace std;


int main()
{
    struct stat buf;
    FILE *pFile;
    pFile = fopen("/centos/zheng.txt", "r");
    int fd = fileno(pFile);
    fstat(fd, &buf);
    long time = buf.st_mtime;
    cout << time << endl;
    fclose(pFile);
}

Logo

更多推荐