
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Write program to shutdown a system in C/C++
A program to shutdown the system works on the operating systems like windows, linux or macOS. To shut it off and close all opened applications.
What shut down or power off means?
Shut down or Power off a computer means removing power from a computer's main components in an organised prescribed way and turning off all the works that are done by the computer i.e. all applications and processings are shut off. After a computer is shut down, the main components such as CPU, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, may access power.
This program turns off, i.e., shut down your computer system. System function of "stdio.h" is to run an executable file shutdown.exe which is present in C:\WINDOWS\system32 folder in Windows.
For Linux program the process is similar and is mentioned below.
For Windows
#include <stdio.h> int main() { system("c:\windows\system32\shutdown /i"); return 0; }
The program works as a command that commands the operating system to close all applications and shutdown the system.
For Linux OS
#include <stdio.h> int main() { system("shutdown -P now"); return 0; }
This is a code that can shut any linux based operating systems. Code directly puts a command for the system which executes it and shuts the system as soon as possible.
- Related Articles
- C/C++ program to shutdown a system?
- Hold shutdown function of the system using shutdown7
- Write a C program of library management system using switch case
- Write a C program to reverse array
- JVM shutdown hook in Java
- C# Program to write a number in hexadecimal format
- Write a program to Delete a Tree in C programming
- Write a C# program to solve FizzBuzz problem
- C# Program to write an array to a file
- Write a program to reverse digits of a number in C++
- Write a program to calculate pow(x,n) in C++
- Write a C program that won’t compile in C++
- Write a C++ Program without Semicolons?
- Write a C# program to find GCD and LCM?
- Write a C# program to do basic arithmetic calculations
