[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: time returns -1

Dale Scheetz writes ("Re: time returns -1"):
> Of all the solutions provided I found:
> jtime = time(&jtime);

How about
  jtime= time(0);

(Or, if you're not using a sensible ANSI C compiler or you're paranoid
or don't include headers or something, "jtime= time((time_t*)0);")

That will be a few microseconds faster, as it won't have to do an
extra kernel-to-user-space copy for writing the time into *&jtime.

Incidentally, if you compiled your earlier program with -Wall -O it
would have told you about the uninitialised variable.

You need to read Kernighan and Ritchie.

Reply to: