stat
Fri Jun 07 2024 04:50:56 GMT+0000 (Coordinated Universal Time)
Saved by
@prabhas
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main() {
struct stat fileStat;
// Get file information
if (stat("file.txt", &fileStat) == -1) {
perror("Error getting file information");
exit(EXIT_FAILURE);
}
// Print file information
printf("File size: %ld bytes\n", fileStat.st_size);
printf("File permissions: %o\n", fileStat.st_mode & 0777);
printf("Last access time: %ld\n", fileStat.st_atime);
return 0;
}
content_copyCOPY
Comments