电脑关机程序

//关机程序

1、电脑运行起来后,1分钟内关机。

2、如果输入:我是猪。就取消关机。

#include<stdio.h>

#include<string.h>
int main()
{
    char input[20] = { 0 };
    system("shutdown -s -t 60");
again:
    printf("请注意,你的电脑在60秒内关机。如果输入我是猪,就取消关机\n");
    scanf("%s", input);
    if (strcmp(input, "我是猪") == 0)
    {
        system("shutdown -a");
    }
    else
    {
        goto again;
    }
    return 0;
}

用while语句替换

#include<string.h>
int main()
{
    char input[20] = { 0 };
    system("shutdown -s -t 60");
    while (1)
    {
        printf("请注意,你的电脑在60秒内关机。如果输入我是猪,就取消关机\n");
        scanf("%s", input);
        if (strcmp(input, "我是猪") == 0)
        {
            system("shutdown -a");
            break;
        }
    }
    
    return 0;
}文章来源地址https://uudwc.com/A/X3rNe

原文地址:https://blog.csdn.net/zy1215058242/article/details/132107448

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

上一篇 2023年08月12日 22:49
【PDF密码】PDF文件不能打印,为什么?
下一篇 2023年08月12日 22:49