Hey guys, is there any way you can clear what a variable holds?
For E.G, if I was to write this:
What code would go after it so that I can clear the integer 'x' and assign it to another number, such as a user input? I'm hoping to do something like this:Code:int x; x = 10; cout << x << endl;
I've actually got a gut feeling I've made a fool of myself in the matter that it's probably as easy as just telling the compiler to overwrite it with another user input.. but hey, no point not getting some professional adviceCode:int pin; int pin_attempt; pin = 2011; cout << "Enter Pin: "; cin.get >> pin_attempt; cin.ignore(); if ( pin_attempt == pin ) { // Don't really have to bore you with this code.. } else { cout << "Incorrect Pin. Please reset: "; // Code to clear the int 'pin' needs to go here? cin.get >> pin; cin.ignore(); }