From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,6abe66868c0ab0b1 X-Google-Attributes: gid1014db,public X-Google-Thread: 1164f8,6abe66868c0ab0b1 X-Google-Attributes: gid1164f8,public From: darcy@druid.com (D'Arcy J.M. Cain) Subject: Re: Help in computing time.... Date: 1995/06/27 Message-ID: #1/1 X-Deja-AN: 105128755 distribution: inet references: <3s884v$7qj@hermes.acs.unt.edu> followup-to: comp.lang.c,comp.sys.dec organization: Planix, Inc., Toronto, Ontario, Canada newsgroups: comp.lang.c,comp.sys.dec 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 --