Skip to content

Instantly share code, notes, and snippets.

@gmunoz
Created December 16, 2014 22:51
Show Gist options
  • Save gmunoz/03a1853a873677f22e8a to your computer and use it in GitHub Desktop.
Save gmunoz/03a1853a873677f22e8a to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
int main(int argc, char *argv[])
{
printf("Hello world\n");
if (argc != 2) {
fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
exit(1);
}
struct stat sb;
if (stat(argv[1], &sb) == -1) {
perror("stat");
exit(1);
}
printf("Last status change: %s", ctime(&sb.st_ctime));
printf("Last file access: %s", ctime(&sb.st_atime));
printf("Last file modification: %s", ctime(&sb.st_mtime));
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment