abort - C stdlib.h

C examples for stdlib.h:abort

Type

function

From

<cstdlib>
<stdlib.h>

Description

Abort current process

Prototype

void abort (void);
void abort() noexcept;

Parameters

none

Return Value

none.

In the following code, if main.cpp does not exist, a message is printed and abort is called.

Demo Code


#include <stdio.h>
#include <stdlib.h>

int main ()/*from w w w .  jav a  2s. com*/
{
  FILE * pFile;
  pFile= fopen ("nonExist.cpp","r");
  if (pFile == NULL)
  {
    fputs ("error opening file\n",stderr);
    abort();
  }
  fclose (pFile);
  return 0;
}

Related Tutorials