Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: darcy@druid.com (D'Arcy J.M. Cain)
Subject: Re: Help in computing time....
Date: 1995/06/27	[thread overview]
Message-ID: <DAuM04.118@druid.com> (raw)
In-Reply-To: 3s884v$7qj@hermes.acs.unt.edu

Falguni Sarkar (sarkar@ponder.csci.unt.edu) wrote:
>I am using a DEC Alpha machine. When I try to compile the
>following code I am facing problems. 

I think you would find it a problem on any platform.  If you want
to be a C programmer it is absolutely essential that you understand
pointers.  Read the FAQ carefully and study your textbook of choice.
If you don't understand pointers you aren't a C programmer.

>time_t tim1,*tp;

You have not initialized tp so, since it is declared outside of any
function, it is initialized as NULL (actually 0 which, in this context,
is a null pointer.)

>main(){
>   tim1=time(tp);

Given that tp is NULL, what does the man page say the effect is?
Look it up.

>   if(tp==NULL)

Since you never changed tp there isn't much point to testing it here.
There is no way for a function to modify a variable if all you send
it is the current value of the variable.  However, if tp were to be
initialized to the address of tim1 (and you don't assign the return
value to tim1 [*]) then time() *will* change the value of tim1 but it
still won't affect tp.

I think what you are trying to do is something like this:

...
tim1 = time(NULL); /* get current time */
... /* do stuff */
tim_diff = time(NULL) - tim1;

[*] actually it would just be redundent.

-- 
D'Arcy J.M. Cain (darcy@{planix|druid}.com)  |  Democracy is three wolves
Planix, Inc., Toronto, Canada                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)     |  what's for dinner.
      -- Info on Planix can be found at http://www.planix.com --



      parent reply	other threads:[~1995-06-27  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-06-21  4:00 Help in computing time Falguni Sarkar
1995-06-21  4:00 ` Derick J.R. Qua-Gonzalez
1995-06-21  4:00 ` Michael W. Walker
1995-06-27  4:00 ` D'Arcy J.M. Cain [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox