ldiv
Calculates the quotient and remainder of the division of a number
#include <stdlib.h> ldiv_t ldiv ( long int numer, long int denom);
This function returns a structure of type ldiv_t that contains the fields quot and rem, which are both of type long int.
The ldiv function calculates the quotient and remainder of the division of the numerator numer by the denominator denom.
#include <stdlib.h> #include <stdio.h> void print_time (long int ticks); { ldiv_t sec_ticks; ldiv_t min_sec; sec_ticks = ldiv (ticks, 100L); min_sec = ldiv (sec_ticks.quot, 60L); printf ("It took %ld minutes and %ld seconds\n", min_sec.quot, min_sec.rem); }
produces the following:
It took 14 minutes and 27 seconds