![]()  | 
![]()  | 
![]()  | 
![]()  | 
![]()  | 
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. | 
Calculate a quotient and remainder
#include <stdlib.h>
div_t div( int numer, 
           int denom );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The div() function calculates the quotient and remainder of the division of numer by denom.
A div_t structure containing the quotient and remainder:
typedef struct {
    int quot;      /* quotient  */
    int rem;       /* remainder */
} div_t;
#include <stdio.h>
#include <stdlib.h>
void print_time( int seconds )
{
     div_t min_sec;
     min_sec = div( seconds, 60 );
     printf( "It took %d minutes and %d seconds\n",
          min_sec.quot, min_sec.rem );
}
int main( void )
{
    print_time( 130 );
    
    return EXIT_SUCCESS;
}
produces the output:
It took 2 minutes and 10 seconds
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | Yes | 
| Signal handler | Yes | 
| Thread | Yes | 
![]()  | 
![]()  | 
![]()  | 
![]()  |