Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::div_t is an STL class returned by std::div.
#include <cassert> #include <cstdlib> int main() { const std::div_t d = std::div(7,3); //Assume the quotient equals (7 / 3) == 2 assert(d.quot == 2); //Assume the remainder equals (7 % 3) == 1 assert(d.rem == 1); }