I am trying to write a code so when I press a key it changes the value of a variable from 0 to 1. When I press it again, it goes back to 0, and so on. Can anyone help?
When you press enter, you type a character (newline), so maybe try using std::cin.get() in a while loop, and every time you read the newline, change the value?