这里我们将看到如何通过编写简单的 c 或 c++ 代码来关闭系统。不同操作系统的关机过程有所不同。如果我们是linux用户,我们可以使用这个终端命令来关闭。
shutdown –p now
如果我们使用windows系统,我们可以使用这个命令 -
c:\windows\system32\shutdown /i
我们将看到适用于 linux 和 windows 的代码
示例(linux)#include<iostream>using namespace std;int main() { system("shutdown -p now");}
示例(windows)#include<iostream>using namespace std;int main() { system("c:\windows\system32\shutdown /i ");}
以上就是关闭系统的c/c++程序?的详细内容。