#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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter