About ~ In A WHILE LOOP ~ Scanf ()

Source: Internet
Author: User

You can often see the while (~ Code such as scanf ("% d", & N) {} indicates that the loop ends when the input ends.

Generally, when the input stream ends, scanf returns EOF.

EOF is a constant defined in the header file stdio. H, which is generally-1.

The source code of-1 is 10000001, the reverse code is 1111110, and the supplementary code is 11111111. Review: The original codes, backcodes, and supplementary codes of positive numbers are the same. The original codes of negative numbers are 1, the original codes of negative numbers are unchanged, and the rest are reversed, the complement is (for the original code) the symbol bit remains unchanged, the rest is reversed, and the last plus 1.

~ EOF is a bitwise inverse operation on the EOF, and the value is 00000000. Therefore, the while condition does not meet and the loop ends.

About ~ In A WHILE LOOP ~ Scanf ()

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.