How do you properly get a variable to update when used as a parameter in a function that is being called the main function?
#include "iostream"
int getUserNumber (int input) {
std::cout << "Please input an integer: ";
std::cin >> input;
return input;
}
int main () {
std::cout << "testing getUserNumber function\n";
int a = 104;
getUserNumber(a);
std::cout << "\n" << a << "\n";
return 0;
}
Whenever I print "a" to test the value, it does not equal what is entered into the console and only returns the value of 104 that it was initially equated to. I am looking for "a" to update from inputted integers such as "6" by using the getUserNumber. Thank you for reviewing my code.