Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Oct 1995 21:54:43 -0600 (MDT)
From:      Dave Andersen <angio@aros.net>
To:        rkw@dataplex.net (Richard Wackerbarth)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Help -- Stupid "C" question.
Message-ID:  <199510270354.VAA27065@terra.aros.net>
In-Reply-To: <v02130500acb5df16dbb7@[199.183.109.242]> from "Richard Wackerbarth" at Oct 26, 95 07:05:19 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Lo and behold, Richard Wackerbarth once said:

> main () {
> printf("It is now %s\n", ctime(time()));
> };
> 
> The last one gave an answer, the rest core dumped.
> 
> What should I use?

Time requires a NULL argument to be passed to it.
The return value from time(NULL) is an integer, whereas ctime() requires 
a pointer to a long int.  Do something like

   long int thetime;
   thetime = time(NULL);
   printf("It is now %s\n", ctime(&thetime));

        -Dave Andersen

-- 
angio@aros.net                Complete virtual hosting and business-oriented
system administration         Internet services.  (WWW, FTP, email)
http://www.aros.net/          http://www.aros.net/about/virtual/
        "She totally confused all the passing piranhas"



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