struct timeval doesn't keep after function returns
int GetTime(struct timeval tv)
{
gettimeofday(&tv, NULL)
printf("%d\n", tv.tv_sec); /* here is the right value */
return 0;
}
int main()
{
struct timeval tv;
GetTime(&tv);
printf("%d\n", tv.tv_sec); /* very wrong value */
gettimeofday(&tv, NULL);
printf("%d\n", tv.tv_sec); /* right again */
}
What happend? struct timeval has a self timer?
Please comment, thanks,
Last edited by legendbb; 06-03-2010 at 10:05 AM.
Reason: Solved
|