Solved

how to use the stat function?

Posted on 2009-04-13
1
4,772 Views
Last Modified: 2012-06-21
Hey, I'm trying to use the stat function to get the time a file was modified, I've been using these two websites as references:
http://www.opengroup.org/onlinepubs/000095399/functions/stat.html
http://linux.die.net/man/2/stat

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(){
  struct stat buff;
  int status;
  status = stat("/home/usra/7e/32407/cisc361/Project#2", &buff);

  printf("%d", buff.st_mtime);

  return(0);
}

This is what I get:
> cc testwatch.c
> ./a.out
1239687531>

I don't understand what that number is... Could someone please explain what it is?

Thanks.

0
Comment
Question by:errang
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 24135245
It is the number of seconds since January 1, 1970
you can use localtime or gmtime to translate it into a struct tm
or ctime to translate it into a character string
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now