w3resource logo

:

C Programming Exercises

C Exercises: Abort the current process

C Variable Type : Exercise-17 with Solution

Write a C program to abort the current process.

Sample Solution:

C Code:

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

int main ()
	{
		FILE * FilePtr;
		FilePtr= fopen ("myfile.txt","r");

		if (FilePtr == NULL)
		{
			fputs ("\n File does not exist or error, in opening the file.\n",stderr);
			abort();
		}

		fclose (FilePtr);

		return 0;
	}

C Programming Code Editor:

Improve this sample solution and post your code through Disqus