C language about the "input contains multiple lines of data, please handle to file end" issue

Source: Internet
Author: User

Today, the author in the University of ACM Network competition, encountered in the input format has such a requirement: the input contains multiple lines of data, please handle to the end of the file. The logic of the topic is very simple, the main function code is easy to implement, but there is no "explicit" in the title of the console to indicate how the input data to end, such as: #, double carriage return, and so on. The author tries to use the CLOCK_T variable control program running time, but the evaluation platform displays "Compile error". After careful analysis, the author gets the answer, "input contains multiple lines of data, please handle to the end of the file" means that when enough data is entered, you can use "Ctrl + Z" to exit the console, that is, "Processing file End", because: Ctrl + Z will make the scanf () function return-1, So when dealing with this type of problem you can take advantage of "while (scanf ("%d%d ", &a,&b)!=eof) {function ()}" To achieve.

C language about the "input contains multiple lines of data, please handle to file end" issue

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.