#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
int main() {
const char* filename = "d:\\data.txt";
struct stat st;
if (stat(filename, &st) == -1) {
perror("stat");
exit(EXIT_FAILURE);
}
printf("File size: %lu bytes\n", st.st_size);
printf("Last change: %s", ctime(&st.st_ctime));
printf("Last access: %s", ctime(&st.st_atime));
printf("Last modification: %s", ctime(&st.st_mtime));
return 0;
}
/*
run
File size: 40 bytes
Last change: Sun Jul 12 10:35:03 2020
Last access: Sun May 02 16:46:35 2021
Last modification: Sun Jul 12 10:35:03 2020
*/