D

Top  Previous  Next

div

#include <stdlib.h>

div_t div (

   int dividend,

   int divisor

);

stand-alone

This function divides dividend by divisor and returns both the quotient and the remainder in a structure of type div_t. This type is defined in stdlib.h and includes the following fields:

 

int quot; // contains the quotient

int rem;  // contains the remainder

 

If the division is inexact, the quotient returned is the integer of lesser magnitude that is nearest to the algebraic quotient. If the result cannot be represented, the behaviour of div is undefined.

disconnect_server

// no header file

extern void disconnect_server (

   int wait

);

 

This function is used in the uncommon cases where a running application wishes to disconnect from the host server but continue to execute. The host I/O system is shut down in the same way as when an application terminates. All file handles (including stdin, stdout, and stderr) are closed and you must make no further reference to them. You should ensure that your application does not have any connections with the host when this call is made (such as connections made by user-defined service clusters).

 

The parameter wait has two possible values:


1

Disconnect and wait for a reply from the server. The call returns only when the server has been reconnected and a Notify message sent.


0

Disconnect and return immediately.

 

The most common use of this function have wait=1. This reopens stdin, stdout, and stderr when the Notify message is received from the server, allowing the use of I/O functions such as printf.

 

Typical usage would be as follows:

 

#include <stdio.h>

extern void disconnect_server(int);

 

main() {

   printf("Disconnecting the server\n");

   disconnect_server(1);

   printf("Server is connected again\n");

}