I have the following code:
tv->tv_sec = malloc(sizeof(time_t));
tv->tv_usec = malloc(sizeof(suseconds_t));
if (gettimeofday(tv, tz) < 0) {
printf("Error getting time of day!\n");
exit(0);
}
printf("%f \n", &tv->tv_sec);
printf("%f \n", &tv->tv_usec);
At compile time I get the following error:
timegettimeofday.c:20: warning: assignment makes integer from pointer without a cast
timegettimeofday.c:21: warning: assignment makes integer from pointer without a cast
And if I run it, the results are:
-1.581093
-1.581093
Could you help me fix this please? What am I doing wrong?
tv->tv_sec = malloc(sizeof(time_t));
tv->tv_usec = malloc(sizeof(suseconds_t));
if (gettimeofday(tv, tz) < 0) {
printf("Error getting time of day!\n");
exit(0);
}
printf("%f \n", &tv->tv_sec);
printf("%f \n", &tv->tv_usec);
At compile time I get the following error:
timegettimeofday.c:20: warning: assignment makes integer from pointer without a cast
timegettimeofday.c:21: warning: assignment makes integer from pointer without a cast
And if I run it, the results are:
-1.581093
-1.581093
Could you help me fix this please? What am I doing wrong?