Latest web development tutorials

C library functions - abort ()

C standard library - <stdlib.h> C standard library - <stdlib.h>

description

C library functionsvoid abort (void) abort the program execution, directly out from the local call.

statement

Here is () statement abort function.

void abort(void)

parameter

  • NA

return value

This function does not return a value.

Examples

The following example illustrates the abort () function is used.

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

int main ()
{
   FILE *fp;
   
   printf("准备打开 nofile.txt\n");
   fp = fopen( "nofile.txt","r" );
   if(fp == NULL)
   {
      printf("准备终止程序\n");
      abort();
   }
   printf("准备关闭 nofile.txt\n");
   fclose(fp);
   
   return(0);
}

Let's compile and run the above program, which will produce the following results, as we try to open a filenofile.txt does not exist:

准备打开 nofile.txt
准备终止程序

C standard library - <stdlib.h> C standard library - <stdlib.h>