Micro Tricky Prank

Micro Tricky Prank


[Preface] Hello, everyone. Today I will arrange a little prank for everyone, if anyone makes you unhappy, you can punish him! Hahahaha, just kidding, everyone should just play on their own computers, so as not to cause any unnecessary trouble.

Ok, come back here, since it is a miniature prank, it needs a code, so where is the code? The code is here,
a simple shutdown program code

//写一个关机程序
//只要程序启动了,就倒计时60秒关机,如果60秒之内,你输入:我是猪 ,就取消关机,否则时间一到电脑就关机了
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    
    
	char input[20] = {
    
     0 };
	system("shutdown -s -t 60");
	while (1)
	{
    
    
		printf("请注意,你的电脑在1分钟之内关机,如果输入,我是猪,就取消关机\n");
		scanf("%s", input);
		//判断一下
		if (0 == strcmp(input, "我是猪"))
		{
    
    
			//取消关机
			system("shutdown -a");
			break;
		}
	}
	return 0;
}

insert image description here

There are some new library functions above. Since I haven’t learned the function, I will briefly introduce it to you:

  • The system() library function is used to execute system commands, and the header file is stdlib.h
  • The shutdown command is a shutdown command provided by windows
  • shutdown -s -t 60 set shutdown after 60 seconds
  • shutdown -a cancel shutdown
  • Note the use of the strcmp() library function, which is used to compare two strings for equality.
  • For comparison of strings, you cannot use ==, but use strcmp(). If the return value is 0, they are equal; if the return value is greater than 0, then s1 < s2; if the return value is less than 0, then s1 > s2

Well, this little prank is still very simple, as long as you know the above points, it will be fine!

Guess you like

Origin blog.csdn.net/m0_68662723/article/details/131857636