?
Solved

how to use the stat function?

Posted on 2009-04-13
1
Medium Priority
?
4,779 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

764 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