Skip to content
 

Last access time for file

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);
}

Sphere: Related Content

Technorati Tags: C Programs, Linux

  • Pingback: ttnrgbgf

  • http://forum.plurielles.fr/membres/hiojk.html cherche viagra

    So why you do this?

    • http://amit-agarwal.co.in/ Amit Agarwal

      sometimes I need to just find if the file was accessed by a application or script?

  • http://www.directpharma.net Buy Generic Viagra

    saw this article bookmarked and truly liked what I read. will definately bookmark it as well and check the other posts when I get home.

  • http://get-rid-of-cellulite.org Get Rid Of Cellulite

    Hey …cheers for the very informative article.I’m really glad I found it on bingKeep up the great work because I for sure will check it out for updates

  • http://get-rid-of-cellulite.org Get Rid Of Cellulite

    Hy …congrats for the well written article.I’m really happy I found it on bingKeep up the wonderfull work because I for sure will visit for updates

  • http://krauzz.com/i-like-it-enrique-iglesias-video.html I Like It Enrique Iglesias Video

    This is a really good read for me. Must admit that you are one of the coolest bloggers I ever saw. Thanks for posting this informative article.