Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::abort

 

std::abort is an STL function to abort the program from any point.

 

In the example below, std::signal sets the function onAbort to handle a possible abort. Then std::abort is called and handled by onAbort.

 

#include <cassert>
#include <csignal>
#include <iostream>

void onAbort(int)
{
  std::cout << "Abort" << std::endl;
}

int main()
{
  std::signal(SIGABRT,onAbort);
  std::abort();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict