Practice Small topics (Assignment 6-18)

Source: Internet
Author: User

int main ()
{
int i=3;
Char x= ' o ';
Char ch;
Tt:ch=getchar ();
GetChar ();
while (i)
{
if (' O ' ==ch)
{
printf ("Login successful \ n");
Break
}
else if (i>0)
{
i--;
printf ("Password error still has%d chance \ n", i);
if (i==0)
{
goto die;
}
goto tt;
}
die:printf ("Zhang brother Daniel \ \");
}
return 0;
}

This is a simulated user logon scenario and can only be logged on three times.

Only three password is allowed, if the password is correct, prompt to log in, if three times the input error, then quit the program.

Key issues:

<1> First say Goto statement, today for the first time use (particularly useful), usage: Must have a logo, the red and blue part of the above, that is the format. It is not advocated at this time because the program is too long and the error will affect the program running logic.

There are big problems, but as far as I can learn the small programs, the two words-too easy to use.

<2> I give the yellow part, need two, because in the black window every time the input needs to enter to determine, enter is also a character (' \ n '), if only write once, Gechar the second time to get the character must be ' \ n ', the program will be a big error, Because every time the input character will put it in a high-speed buffer area, every time GetChar () it will be in the buffer area to read, and after empty, it may be necessary for you to enter.

Practice Small topics (Assignment 6-18)

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.