how to shutdown system c++
To shutdown a system using C++, you can use the system()
function and pass the appropriate command as an argument. Here's an example:
#include <cstdlib>
int main() {
system("shutdown -s -t 0");
return 0;
}
This code will call the system()
function with the command "shutdown -s -t 0"
, which instructs the system to shut down immediately (-s
) without any delay (-t 0
).
Please note that shutting down a system programmatically can have serious consequences, so use this code with caution.