Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Apr 2006 08:17:34 -0500
From:      "Conrad J. Sabatier" <conrads@cox.net>
To:        "jiangyong jon7808" <jon7808@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: gcc problem, I can't get the 'ctime(&(statbuf.st_atime)' value in line20.
Message-ID:  <20060428081734.67014428@localhost>
In-Reply-To: <40b94f630604280122v72c432dfx2f3c2e11a220a82e@mail.gmail.com>
References:  <40b94f630604280122v72c432dfx2f3c2e11a220a82e@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 28 Apr 2006 16:22:10 +0800, "jiangyong jon7808"
<jon7808@gmail.com> wrote:

>       1 #include <sys/stat.h>
>       2 #include <errno.h>
>       3 char *filename = "/etc/passwd" ;
>       4
>       5 int main()
>       6 {
>       7     struct stat statbuf;
>       8
>       9     if(stat(filename,&statbuf)==-1)
>      10     {
>      11         printf("Get stat on %s Error:%s\n",
> filename,strerror(errno));
>      12         return(-1);
>      13     }
>      14
>      15     printf("Filename: %s\n", filename);
>      16     printf("Size: %ld\n", statbuf.st_size);
>      17     printf("Access Date: %s", ctime(&(statbuf.st_atime)));
>      18
>      19     printf("%s size: bytes\taccessed at %s",
> filename,ctime(&statbuf.st_atime));
>      20     printf("%s size:%ld bytes\taccesed at %s", filename,
> statbuf.st_size,ctime(&(statbuf.st_atime)));
>      21     printf("\n**********************The
> end!*************************\n") ;
>      22 }
> 
> 
> 
> 
> 
> OS :FreeBSD 6.1-RC #36

Works fine here:

$ ./foo
Filename: /etc/passwd
Size: 6073
Access Date: Wed Apr 26 04:07:15 2006
/etc/passwd size: bytes accessed at Wed Apr 26 04:07:15 2006
/etc/passwd size:6073 bytes     accessed at Wed Apr 26 04:07:15 2006

**********************The end!*************************

-- 
Conrad J. Sabatier <conrads@cox.net> -- "In Unix veritas"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060428081734.67014428>