Hi guys all of we know how to shutdown the PC using batch file or by normal method.But have you ever tried to shutdown your PC using C program.If not in this tutorial i am gonna teach you how to shutdown your PC by writing a simple c program.so lets see how to do this.
2.Finish.
Steps:
1.Open any c program compiler and copy the below code.
Code to shutdown the PC:
For windows 7:
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>//optional
main()
{
char ch;
printf("Do you want to shutdown your system yes or no\n");
scanf("%c",&ch);
if (ch == 'Y' || ch == 'y')
system("C:\\WINDOWS\\System32\\shutdown /s");// s-shutdown r-restart l-logoff h-hibernate
getch();//you can use return 0; instead of getch();
}
Note:
- S-Shutdown.
- r-Restart.
- l-Log off.
- h-Hibernate.
For windows XP:
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
main()
{
char ch;
clrscr();
printf("Do you want to shutdown your system yes or no\n");
scanf("%c",&ch);
if (ch == 'Y' || ch == 'y')
system("C:\\WINDOWS\\System32\\shutdown -s");// s-shutdown r-restart l-logoff h-hibernate getch();//you can use return 0; instead of getch();
}
That's it friends i hope you enjoyed the article and if you have any ideas or any queries regaridng any topic feel free to ask us through comments and have a nice day.
Comments
Post a Comment