Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    ldiv_t ldiv( long int numer, long int denom );

    typedef struct {
        long int quot;     /* quotient */
        long int rem;      /* remainder */
    } ldiv_t;

Description:
    The ldiv function calculates the quotient and remainder of the division
    of the numerator numer by the denominator denom.

Returns:
    The ldiv function returns a structure of type  ldiv_t that contains the
    fields  quot and  rem, which are both of type long int.

Example:
    #include <stdio.h>
    #include <stdlib.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 );
      }

    void main()
      {
        print_time( 86712L );
      }

    produces the following:

    It took 14 minutes and 27 seconds

Classification:
    ANSI

Systems:
    All, Netware

See Also:
    div

See Also: div

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson