Solved

how to use the stat function?

Posted on 2009-04-13
1
4,774 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XCode crashes while uploading to app store. 5 262
Why does module make constant click noise ? 9 130
Problem to show menu 5 88
Super Scope, DHCP 5 77
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

777 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