C. C + + Tutorial: C Language timed off applet

Source: Internet
Author: User

Today for everyone to bring two a C language Small program sharing, the need for practical application of the role is not very small, but it is definitely helpful to you! In the future, the small series will be regularly released some: a C language Small program source code + comments + answers, to enrich everyone's knowledge!

#include <stdio.h>

#include <string.h>

#include <stdlid.h>

void Main ()

{

Char cmd[20]= "shutdown-s-T";

Char t[5]= "0";

int C;

System ("Title C language Shutdown program"); Set CMD Window caption

System ("mode con cols=48 lines=25"); Window width Height

System ("Color F0"); You can write red to bring up the color group

System ("date/t");

System ("time/t");

printf ("-----------C language shutdown program-----------\ n");

printf ("1. Achieve a timed shutdown of the computer within 10 minutes \ n");

printf ("2. Turn off the computer immediately \ n");

printf ("3. Log off the computer \ n");

printf ("0. Exit system \ n");

printf ("-------------------------------------\ n");

scanf ("%d", &c);

Switch (c) {

Case 1:

printf ("How many seconds do you want to turn off the computer automatically?" ( 0~600) \ n ");

scanf ("%s", T);

System (strcat (cmd,t));

Break

Case 2:

System ("Shutdown-p");

Break

Case 3:

System ("Shutdown-l");

Break

Case 0:

Break

Default

printf ("error!\n");

}

System ("pause");

return 0;

This program is of little practical value, but it allows us to understand the system () function. Under Windows, the System () function can execute DOS commands, and in Unix/linux, the shell can be executed. Please run the above program under Windows. In the program, the DOS interface is set up and the shutdown function is implemented by DOS command.

C. C + + Tutorial: C Language timed off applet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.