Home > Back-end >  Or about the if statement
Or about the if statement

Time:10-02

Why do I try to input some non-numeric values, such as A, it will be before I enter the second value directly is output 1

CodePudding user response:

Don't input integer value, the input character, although they can read input system of characters, but is not stored in the previously defined variable, the program output 1, should is because the system to the two variables are initialized values are the same,
"Program ranging from input as to what you say the second value is directly output 1", I didn't meet this situation, I input the two characters then press the enter key after the program to output 1,

CodePudding user response:

reference 1st floor ipanda_huanhuan response:
input integer value, the input character, although will read input characters, but is not stored in the previously defined variable, the program output 1, should is because the system to the two variables are initialized values are the same,
"Program ranging from input as to what you say the second value is directly output 1", I didn't meet this situation, I input the two characters then press the enter key after the program to output 1,

I checked the, because the return itself is entered

CodePudding user response:

Type the type of data and requirements do not match, the scanf function will be terminated at this moment, thus ignore the back of the input, so I typed one character at a time, press the enter to the scanf function will feel that the first data is entered, but found that types do not match, so the termination of the input, the required input is character, enter and Spaces is input

CodePudding user response:

The building Lord, why am I the same code, just add the print, the result is different from yours,
Code:
# include "stdio.h"

Void main ()
{
Int a, b;
Printf (" before the scanf - Func: a=% d, b=% d \ n ", a, b);
The scanf (" % d % d ", & amp; A, & amp; B);
Printf (" after the scanf - Func: a=% d, b=% d \ n ", a, b);
If (a==b)
{
Printf (" logic print 1 \ n ");
}
return;
}
Results:
Before the scanf - Func:=a=134513969, b - 1078386884
A
After the scanf - Func:=a=134513969, b - 1078386884

????
  • Related