include using namespace std; int main() { cout << "Press the ENTER key"; if (cin.get() == '\n') { cout << "Good job.\n"; } else { cout << "I meant ONLY the ENTER key... Oh well.\n"; } return 0; } This code will help in detecting the ENTER key when pressed....
It seems that the newline is assumed CR (= 13). But it can be LF (= 10). Please try to add one more condition to the while loop: while((ch=mygetch()) != EOF || ch != 10 || ch != 13 || z<sizeof(password)-1) { ...
This is because getch() reads not only the character you do input, but also the new line feed. You do actually write some_character and \n into the input stream. Both are characters and both are read. You need to ignore rest of the stream, after the 1st character read. Another...
c,loops,if-statement,scanf,getch
You should really check the return value of scanf() for successful completion. Check the man page here. Otherwise, even if scanf() fails, you condition check(s) will keep on executing, possibly with wrong value in Choice. Note: If the very first time scanf() fails, you'll be encountering a read-before-write secnario [if...
As your compiler is telling you, getche has not been defined. Usually, you would include a header (e.g. #include <conio.h>) that will define the function somewhat similar to: int getche(void); There is a rule for the C language that allows usage of functions which have not been defined before. These...