I'm having trouble with this basic program. I'm 100% lost when it comes to this, I have written much more complex programs...solving Sudoku Puzzles and such, I however have taken a break from coding and am working on learning Object Oriented programming.
Everything functions properly, however the Do-While loop continues forever because INT key does not equal 3 in this function, when i print the value of key in that function it shows up completely random like (170,000 + 900,000)I'm assuming these are memory values. This is a basic assignment from my old textbook, the idea is to not modify the function main. All of my #includes are correct but are in a header file.
By default, C++ parameters are "pass by value." This means that the key variable in main and the key variable in getKey are completely different variables. Although you return the updated key value at line 28, the code at line 16 doesn't do anything with it.
Yanson's change assigns the return value from getKey() back to main's key variable.