top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

write a program in C to know the last modification date of a file?

+7 votes
368 views

Can anybody suggest how can we create a program in C to know the last modification date of any file?

posted Dec 16, 2013 by Neeraj Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Function is gmtime and covert into string. Try something like this -

char *get_last_modified(char *file) {
    struct tm *clock;
    struct stat attr;

    stat(file, &attr);
    clock = gmtime(&(attr.st_mtime));

    return asctime(clock);
}
answer Dec 16, 2013 by Satish Mishra
...