- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C/C++ program to shutdown a system?
Here we will see how we can shut down the system by writing a simple C or C++ code. The shutdown process varies in different OS. If we are Linux user, 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 "); }
Advertisements