Is there a C++ function to turn off the computer?

后端 未结 6 2272
悲&欢浪女
悲&欢浪女 2020-12-30 16:51

Is there a C++ function to turn off the computer? And since I doubt there is one (in the standard library, at least), what\'s the windows function that I can call from C++?

6条回答
  •  滥情空心
    2020-12-30 17:14

    You can shutdown by utilizing the system() function.

    for Windows

    system("shutdown -s");
    

    for Linux

    system("poweroff");
    

    or

    system("init 0");
    

提交回复
热议问题