I am having a hard time adding two long ints, essentially what I want is the 'total' time it took using these two variables and I keep on getting 0.
struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage);
printf("TOTAL TIME \n");
printf("%ld.%06ld", (rusage.ru_utime.tv_sec, rusage.ru_utime.tv_usec),
(rusage.ru_stime.tv_sec, rusage.ru_stime.tv_usec));
It prints out a 0. I am able to print out the the user time, system time, but I can't add them. Please help.
What the author wants isn't to add just two long
integers, but to add two timeval
structures' seconds and microseconds respectively.