#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

typedef struct {
  // if you allocate pointers here...
  struct timeval *tv;
  struct timezone *tz;
} Time;

Time *make_time ()
{
  Time *time = (Time *) malloc (sizeof(Time));

  // ... then you have to allocate structures for the pointers to
  // point to!
  time->tv = (struct timeval *) malloc (sizeof(struct timeval));
  time->tz = (struct timezone *) malloc (sizeof(struct timezone));
  return time;
}

double get_seconds(Time *time)
{
  return time->tv->tv_sec + time->tv->tv_usec / 1e6;
}

int get_time(Time *time)
{
  return gettimeofday(time->tv, time->tz);
}

int main()
{
  Time *time = make_time();
  get_time(time);

  double x = get_seconds(time);
  printf ("%f\n", x);
}
