Home > Back-end >  Why is the size of the two integers, the output is always the first number?
Why is the size of the two integers, the output is always the first number?

Time:01-21

To give you an idea of BBS teachers and seniors happy New Year, wish your family peace and reunion, everything goes well,
Next is by reading Tan Haoqiang teachers "C programming" (fifth edition) from learn C language programming, the case in the book of 1.3 "for the two integers supplied," in my win10 operating system of visual studio 2019 tried the following code to compile environment, compared with the teaching material, only have replaced the scanf in order to "scanf_s", the other no subjective changes, but now the input two integers, after 99100, for example, the larger value of program are given was 99; 100 13 if the input, the output is 100, should be the input of the first two integers only output as a result, I checked several times, however, did not find the reason, so here you teacher, also please patience under the guidance of my this beginner, thank you very much!
The code is as follows:

# include
Int main ()
{
Int Max (int x, int y);
Int a, b, c;
Scanf_s (" % d, % d ", & amp; A, & amp; B);
C=Max (a, b);
Printf (" Max=% d \ n ", c);
return 0;
}
Int Max (int x, int y)
{
Int z;
If (x & gt; Z=x y);
The else z=y;
return(z);
}

CodePudding user response:

Most likely when you enter a comma, in the Chinese scanf_s (" % d, % d ", & amp; A, & amp; B); % d % d a comma, need you input half Angle of commas

CodePudding user response:

As you enter 3 full horn comma 1, then the second number receiving can be a problem, so it is always the first

CodePudding user response:

Thanks to the upstairs timely and patience and detailed reply, I just tried it, that's true, problem solved, thank you very much!

CodePudding user response:

I also met the same problem, but I am using is a comma in English?
  • Related