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 the standard input/output header file.
#include<stdlib.h> // Include the standard library header file.
int main () // Start of the main function.
{
FILE * FilePtr; // Declare a pointer to a file 'FilePtr'.
FilePtr= fopen ("myfile.txt","r"); // Open the file "myfile.txt" in read mode.
if (FilePtr == NULL) // Check if the file could not be opened.
{
fputs ("\n File does not exist or error, in opening the file.\n",stderr); // Print an error message.
abort(); // Terminate the program abnormally.
}
fclose (FilePtr); // Close the file.
return 0; // Return 0 to indicate successful execution of the program.
} // End of the main function.
Flowchart:

C Programming Code Editor:
Previous: Write a C program to return the absolute value of an integer.
Next: Write a C program to demonstrate the working of keyword long.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join