time() function in time.h

time() function in time.h

Post by David Schwart » Tue, 28 Nov 2000 04:00:00




> i encounter a strange problem in the time() function defined in time.h

> void test() {
> time_t *t;

>    time(t);
> }

> int main(){
> time_t *t;

>    time(t);
> //   test();

> }

> the strange thing is, the function works well in the main method.
> but i will get a segmentation fault if i try to call time() through the
> function test().

> anybody know what's wrong?

        You need to initialize 't' before you use it. You got lucky in one case
and 't' happened to contain a reasonable value. In the other case, you
didn't get lucky.

        DS

 
 
 

time() function in time.h

Post by tech.. » Wed, 29 Nov 2000 16:42:59


i encounter a strange problem in the time() function defined in time.h

void test() {
time_t *t;

   time(t);

Quote:}

int main(){
time_t *t;

   time(t);
//   test();

Quote:}

the strange thing is, the function works well in the main method.
but i will get a segmentation fault if i try to call time() through the
function test().

anybody know what's wrong?

thanks.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

time() function in time.h

Post by John Gord » Wed, 29 Nov 2000 04:00:00



> i encounter a strange problem in the time() function defined in time.h
> void test() {
> time_t *t;
>    time(t);
> }
> int main(){
> time_t *t;
>    time(t);
> //   test();
> }
> the strange thing is, the function works well in the main method.
> but i will get a segmentation fault if i try to call time() through the
> function test().
> anybody know what's wrong?

yes.  t is an uninitialized pointer.

you were "lucky" (unlucky, really) that it worked in main().

---
"... What with you being his parents and all, I think that you could
be trusted not to shaft him."  -- Robert Chang, rec.games.board


 
 
 

time() function in time.h

Post by tech.. » Thu, 30 Nov 2000 13:25:30





> > i encounter a strange problem in the time() function defined in
time.h

> > void test() {
> > time_t *t;

> >    time(t);
> > }

> > int main(){
> > time_t *t;

> >    time(t);
> > //   test();

> > }

> > the strange thing is, the function works well in the main method.
> > but i will get a segmentation fault if i try to call time() through
the
> > function test().

> > anybody know what's wrong?

> yes.  t is an uninitialized pointer.

> you were "lucky" (unlucky, really) that it worked in main().

> ---
> "... What with you being his parents and all, I think that you could
> be trusted not to shaft him."  -- Robert Chang, rec.games.board



thanks for the replies

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. convert UT time in local time / local time in UT time

hello,

    I try to make a fonction to convert a local time in UT time. i try to
use
     mktime + gmtime + timezone + daylight.... but the result is not OK.
    Please help me....
    The problem is the same when i try to convert a UT time in Local
Time....

    my imput date format is : 'YYYYMMDDHHMMSS'.

    I'am a beginner on Unix (and in english).....

    Does anyone know about a function or an example (in C) .

    Thanks for any help.

2. Alternative to automonitoring

3. time time time how can I tell the time

4. help! exported kernel symbols ?

5. Need help with 'time' C Run-Time Library functions under HP-UX

6. kernelpanic--> auto reboot ?!

7. Recommended time function for time stamp within a device driver?

8. forgot about something

9. Daylight time (label) but standard time (time)

10. Daylight Savings time, system time, hardware time....

11. hda : irq time out {busy} from time to time

12. Is the time in gprof CPU time or elapsed time?

13. Time, NTP, cron wrong time