what im trying to do is have the message display only when the keyboard is hit. the problem im having is that once a button is hit, it continuously loops the message. how can i just key the message to display only when a key is hit?Code:#include <iostream.h> #include <conio.h> #include <stdio.h> int main() { while(1) { if (kbhit()) { cout << "The keyboard has been hit" <<endl; fflush(stdin); } } return 0; }
also, as u can see, i tried flushing the stdin, but that didnt work.
thanks !