Table of Contents

abort

    #include <stdlib.h>
    void abort(void);

Cause abnormal program termination, and try to catch SIGABRT.

no return value

C Sourcecode Example

#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 /* for printf */
#include <stdlib.h>
int main( void )
{
  int x=2,y=5,i;
  i=x+y;
 
  printf("x = %i | y = %i\n", x, y);
 
  abort();
 
  /* will never execute, abort will terminate the programm */
  printf("result of %i+%i= %i", x, y, i);
 
  return 0;
}

output with abort:

  user@host:~/code-reference.com# ./abort
  x = 2 | y = 5
  aborted

output without abort

  user@host:~/code-reference.com# ./abort
  x = 2 | y = 5
  result of 2+5= 7