How to shutdown a PC using C program ?

To shutdown a PC using C, we may use system() function present in the stdlib.h (header file : standard library).



void main()
char choice;

printf(“Press ‘Y’ to Shutdown Your PC : “);

 if(choice==’Y’ || choice==’y’)
 system(“C:\WINDOWS\System32\shutdown /s”);   
 printf(“Shutdown Aborted !!!”);

NOTE:  use -s instead of /s , if you are using windows XP.





Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.