Home > Back-end >  C language small white, is this statement under the if (ch <'0' | | ch> '9'
C language small white, is this statement under the if (ch <'0' | | ch> '9'

Time:02-06

 
Int main ()
{
Int ch=0;
While ((ch=getchar ())!=(EOF)
{
If (ch & lt; '0' | | ch> '9')
continue;
Putchar (ch);
}
return 0;
}


Bigwigs doubt dispels doubts, why is this code 0 or 9 or can be 0 or 9

CodePudding user response:

The
refer to the original poster unclekingfish response:
 
Int main ()
{
Int ch=0;
While ((ch=getchar ())!=(EOF)
{
If (ch & lt; '0' | | ch> '9')
continue;
Putchar (ch);
}
return 0;
}


Bigwigs doubt dispels doubts, why is this code 0 or 9 can be 0 or 9

If statement inside the parentheses wrong
Should be the if (ch>='0' | | ch<='9')

CodePudding user response:

reference 1st floor is the healing of burning flesh see ~ reply:
Quote: refer to the original poster unclekingfish response:
 
Int main ()
{
Int ch=0;
While ((ch=getchar ())!=(EOF)
{
If (ch & lt; '0' | | ch> '9')
continue;
Putchar (ch);
}
return 0;
}


Bigwigs doubt dispels doubts, why is this code 0 or 9 can be 0 or 9

If statement inside the parentheses wrong
Should be the if (ch>='0' | | ch<='9')

Just got the wrong number, the answer upstairs | | to & amp; &
  • Related