Last access time for file
2010-02-03
96 words
1 min read
The C program will print the last access time for the file.
This is quite helpfull program when you want to find old files. Modifying the source to take the filename as argument and take multiple arguments is left as an exercise.
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
int main(void)
{
char datestring[80];
struct stat a;
//int fd = open("ak",O_RDONLY);
if (stat ("iptc.c", &a) == -1) {
perror("stat");
printf (" Error");
return;
}
printf (" Last Access Time is %s", ctime(&a.st_atime));
printf (" Last Access Time is %s", a.st_atime);
}
Related Articles:
- 2010/02/03 Built-in lists in vim
- 2010/01/28 Understand Awk Variables with 3 Practical Examples
- 2010/01/24 statifier — Dynamic to Static
- 2010/01/24 Short Information about loaded kernel modules
- 2010/01/21 Copy temporary evolution images downloaded for messages
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.