Program:
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
void main()
{
struct stat stbuf;
stat("alphabet",&stbuf);
printf("Access time = %d\n",stbuf.st_atime);
printf("Modification time = %d\n",stbuf.st_mtime);
printf("Change time = %d\n",stbuf.st_mtime);
}
The above program gives the following output:
Output:
$ ./a.out
Access time = 1441619019
Modification time = 1441618853
Change time = 1441618853
$
It print the date in seconds. In C, what is the way to print the time as human readable format which is returned by stat function. Return type of stbuf.st_atime is __time_t.
Thanks in Advance...