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++?
yes! for Windows XP:
#include
#include
int main()
{
char ch;
printf("Do you want to shutdown your computer now (y/n)\n");
scanf("%c", &ch);
if (ch == 'y' || ch == 'Y')
system("C:\\WINDOWS\\System32\\shutdown -s");
return 0;
}
For Windows 7
system("C:\\WINDOWS\\System32\\shutdown /s");
For Linux
system("shutdown -P now");