Unknown scanf, unknown scanf

Source: Internet
Author: User

Unknown scanf, unknown scanf
This is an article for Tan Bai.

A few days ago, I saw someone in the group saying that tan haoqiang's book is not that bad and there are still many mistakes. I looked at his error.

1 # include <stdio. h> 2 int main () {3 int a, B; 4 scanf ("% d, % d", & a, & B ); 5 printf ("% d", a, B); 6}

The man said that some of the Code provided in the book had problems with basic input:

Why does 20 get in with only 15 inputs?

First, initialize a and B to 0 to check the problem.

The result shows that the value of a has changed, but the value of B is 0, which means that B is not stored. Why?

This is because,The input of the scanf function must be the same as the format you set earlier.For example

Only when your input matches your set "% d, % d" can you store it correctly

 

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.