i would like some examples of simple c or c++ codes that can shut down a computer like say at exactly 9pm.

could anyone give me a sample c code that can pop up on the screen warning that the computer will shut down in 20 minutes.

Recommended Answers

All 2 Replies

This is the part where we sit around guessing which OS/Compiler you have, and whether or not you have admin privileges on the machine in question.

Some windows, and all Unix/Linux operating systems have the concept of 'shutdown' to take a machine down in an orderly fashion, and the concept of 'at' for arranging things to happen at predetermined times in the future. Perhaps play with these to achieve what you want.

In unix use cronjob, in windows create a service and call shutdown
I hope you are not asking us to code your homework.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.