Home > Back-end >  About the ASCII input
About the ASCII input

Time:09-26

#include
Int main () {
Int b;
B=6;
While (getchar ()!=b)
Printf (" ");
Printf (" does not perform ");
return 0;
}
In what way the input ASCII characters "ACK", while judgment is false?
If I enter the ACK, I will only in A single character to calculate A C K









Before have a similar problem, let me know my mistake, also know that the single character input can be directly,
Such as the b=6 b=54 instead, and then directly enter 6, will only print does not perform after running,

CodePudding user response:

At the same time press Ctrl and F

CodePudding user response:

ASC problems
Int main () {
Char STR [5].
While (gets (STR)!="ACK")
Printf (" ");
Printf (" does not perform ");
return 0;
}
//getchar () function returns the obtaining of ASCII characters, such as your input is 6 use getchar (), he is the return value of the 54
//b=54, only your variables will only while the condition is true or directly make getchar ()!
='6'Int main () {
Int b=54;
//while (getchar ()!=b)
While (getchar ()!='6')
Printf (" ");
Printf (" does not perform ");
return 0;
}

CodePudding user response:

Sorry, I'm using my mobile phone in online IDE input, so want to know about the,

CodePudding user response:

The
reference dared to 001 on the second floor response:

ASC problemInt main () {
Char STR [5].
While (gets (STR)!="ACK")
Printf (" ");
Printf (" does not perform ");
return 0;
}
//getchar () function returns the obtaining of ASCII characters, such as your input is 6 use getchar (), he is the return value of the 54
//b=54, only your variables will only while the condition is true or directly make getchar ()!
='6'Int main () {
Int b=54;
//while (getchar ()!=b)
While (getchar ()!='6')
Printf (" ");
Printf (" does not perform ");
return 0;
}

Thank you very much for your reply, I learned a lot from your reply, but I still have a question: if I want to enter the characters in the ASCII character set, such as "ACK", and then to the value of 'ACK' representatives' 6 'as a judge, so I input "ACK" in what ways?
In your first program listed and how should I enter can not perform the while loop?
ACK, I use online IDE test, input the while loop will still be implemented,

CodePudding user response:

Fool some reserved characters can only control the virtual keyboard input

CodePudding user response:

 char STR [5]; 
While (STRCMP (gets_s (STR), "ACK")!=0)//to use STRCMP () to determine whether equal, 0 means equal, non-zero unequal
{
Printf (" ");
}
Printf (" does not perform ");

Need to add the header file
 include & lt; String. H> 

CodePudding user response:

jing is language reference 5 floor response:
fool some reserved characters can only control the virtual keyboard input

Oh! Thank you for your reply.

CodePudding user response:

Oh, thank you for your reply,

CodePudding user response:

refer to 6th floor MianHou response:
 char STR [5]. 
While (STRCMP (gets_s (STR), "ACK")!=0)//to use STRCMP () to determine whether equal, 0 means equal, non-zero unequal
{
Printf (" ");
}
Printf (" does not perform ");

Need to add the header file
 include & lt; String. H> 

Oh! Thank you for your reply.
  • Related