Solved

how to use the stat function?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
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 and use conditional statements in the C programming language.

863 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

28 Experts available now in Live!

Get 1:1 Help Now