stat.c 383 B

12345678910111213141516171819
  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <sys/stat.h>
  4. #include <unistd.h>
  5. int main() {
  6. printf("%ld\n", sizeof(struct stat));
  7. struct stat buf;
  8. if (stat("unistd/stat.c", &buf)) {
  9. perror("stat");
  10. return 1;
  11. }
  12. printf("st_mode: %u\n", buf.st_mode);
  13. printf("st_size: %lu\n", buf.st_size);
  14. printf("st_blksize: %lu\n", buf.st_blksize);
  15. }