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

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

WBOY
Release: 2023-09-12 19:13:02
forward
945 people have browsed it

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
Copy after login

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

c:\windows\system32\shutdown /i
Copy after login

We will see the code for Linux and Windows

Example (Linux)

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

Example (Windows)

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

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template