Mohd Khalid Kasmin wrote:
> I tried the following progam to test my understanding of struct.
> It seems to work if I just declare one pair struct variable the way
> it is in the program. If I declace two pairs struct variables say
> like this
>
> struct timeval *t1;
> struct timezone *z1;
> struct timeval *t2;
> struct timezone *z2;
This doesn't declare any structures. It declares pointers, which you
aren't initialising. The correct usage is:
struct timeval t1;
struct timezone z1;
gettimeofday(&t1, &z1);
Also, note that you can pass NULL for either parameter if you aren't
interested in retrieving that information, e.g.
struct timeval t1;
gettimeofday(&t1, NULL);
will just return the time, and not the time zone.
--
Glynn Clements <[EMAIL PROTECTED]>