Welcome, Guest: Join Nigeria Student Forum / Login / Trending Now / Recent

Stats: 17,479 members, 69,439 Topics, 15,458 Comments. Date: Jun 19 2019, 8:51 pm

Mathew Oluwaseun
University of Ilorin (Unilorin)
Mechanical Engineering
500Level, Nigeria.

To shutdown your computer using C program, You'll need to call the system() function which will call the cmd.
stdlib.h contain the system() function and it is used to run any executable file.

C Program Code -

void main()
char c;
printf("Do you want to shutdown your PC/Computer (y/n) : ";
if(c=='y' || c=='Y')
system("C:\Windows\System32\shutdown /s /t 0";
printf("You don't wanna shut down your PC/Computer";

Note - Save the file with .c extension.
/s represents shutdown
/t represents Time means after how much time you wanna shut down your pc. If you will not define the time, By default it will shut down your pc after 30sec.

0 Like

Don not get stuck at the well of argument. Let God be your vindicator. Let Him fight your battles. He will vindicate you better than you can vindicate yourself.

Don't have an account? Use the form below to signup for a Nigeria Student Forum Account

Full Name:
Username: E.g Seuncoded
Confirm Password:

I agree to the terms of service

Viewing this topic:
1 guest viewing this topic
Download the Ngstudentforum app for Android Devices

Disclaimer: Every Nigeria Student Forum member is solely responsible for anything that he/she posts or uploads on Nigeria Student Forum.
- Copyright © 2016 - 2019. All rights reserved.
For enquiries & feedbacks send email to: Ngstudentforum@gmail.com