A small example of infinite input (from the great God Classmate Friendship guidance)

Source: Internet
Author: User
#include <stdio.h>
int main (void)
{
int A, B;
while (scanf ("%d%d", &a, &b) ==2)
printf ("%d\n", a+b);
return 0;
}SCANF ("%d,%d,%d", &a,&b,&c); if there is a comma between the%d,%d,%d, enter the data with a comma, if the comma is omitted, the input is not a comma, and the Space, TAB key or enter to separate the individual data return value of scanf

The scanf () function returns the number of data items that were successfully assigned, and EOF is returned when an error is read to the end of the file.

Such as:

scanf ("%d,%d", &a, &b);

If both A and B are read successfully, then the return value of scanf is 2.

If only a is successfully read in, the return value is 1

If both A and B are not successfully read, the return value is 0

If an error is encountered or an end of file is encountered, the return value is EOF.

And the return value is of type int.

A small example of infinite input (from the great God Classmate Friendship guidance)

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.