Home  >  Article  >  Backend Development  >  C/C++ program that shuts down the system?

C/C++ program that shuts down the system?

WBOY
WBOYforward
2023-09-12 19:13:02865browse

C/C++ program that shuts down the system?

Here we will see how to shut down the system by writing simple C or C code. The shutdown process varies between operating systems. If we are Linux users, we can use this terminal command to shut down.

shutdown –P now

If we are using Windows system, we can use this command -

c:\windows\system32\shutdown /i

We will see the code for Linux and Windows

Example (Linux)

#include<iostream>
using namespace std;
int main() {
   system("shutdown -P now");
}

Example (Windows)

#include<iostream>
using namespace std;
int main() {
   system("c:\windows\system32\shutdown /i ");
}

The above is the detailed content of C/C++ program that shuts down the system?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete