Interesting C language applets

Source: Internet
Author: User

Interesting C language applets
Determine the output content of the following program:

#define _CRT_SECURE_NO_WARNINGS 1#include <stdio.h>#include <stdlib.h>int main() {     int i=43;       printf("%d\n",printf("%d",printf("%d",i)));      system("pause");      return 0; }

 

This is a very simple program, which mainly uses the printf output of C language. The program first executes the most internal printf, that is, the output of the I value in the form of an integer, the output content is 43, then execute the printf next to the outside, that is, output 43 digits 2. Similarly, execute the outmost printf, and output 2 digits 1, so the final output result of the program is 4321. play with you: Execute the program :.. shutdown in 60 seconds .. show "say you're a pig! Otherwise shut down ".. if the input is "I am a pig ".. then cancel the shutdown .. if the input is not "I am a pig ".. so do not cancel .. the specific program is as follows:
# Include <stdio. h> # include <stdlib. h> # include <string. h> int main () {char write [100]; system ("shutdown-s-t 60"); // shutdown command. This value is 60 seconds and can be set as needed. gt: printf ("let's say you're a pig! Otherwise, shut down! \ N "); scanf (" % s ", write); if (strcmp (write," I am a pig ") = 0) // strcmp is the string comparison function {printf ("Haha, you are a pig ~ \ N "); system (" shutdown-a ");} else {printf (" isn't it? If you don't talk about it, just wait for the shutdown! \ N "); goto gt; // goto statement, the program will jump to the place with the gt mark for execution} return 0 ;}

 

 

Related Article

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.