Solved

how to use the stat function?

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
How to get time_t value that is a week old 6 169
C dll call freezes 5 112
change colour of repeater control in asp.net c# 7 137
Resolve Dependency Issues 4 85
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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

733 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