Re: Stat mod time

From: Jeremy Elson (jelson@blaze.cs.jhu.edu)
Date: 09/07/94


> Ok, thanks for all the help - things were looking good until...
> 
> This is the code I've got:
> 
> struct stat *statbuf;
> time_t modified_time;
> 
> stat(MOTD_FILE, statbuf);
> modified_time = statbuf.st_mtime;          /* this is line 1722 in the code *

The above code is wrong.  statbuf as you've declared it is a pointer to a
structure, meaning you should use '->' instead of '.' to reference structures.
But, there's the additional problem that you haven't actually initialized
statbuf to point to anything in particular so it will most certainly crash
if you try to run it.  The code should read:

struct stat statbuf;
time_t modified time;

stat(MOTD_FILE, &statbuf);
modified_time = statbuf.st_mtime;

J



This archive was generated by hypermail 2b30 : 12/07/00 PST