Just curious, but can a pointer accept user input?
For example, would the following code work:
Code:#include <iostream> using namespace std; int f(int* p) { if (*p == 1) cout << "You entered 1. Good guess." <<endl; else { cout << "Wrong guess, please try again." <<endl; cin >> *p; } } int main() { int x; cout << "Please input a number:"<< endl; cin >> x; f(x); for ( ; x != 1; ; ) { cout << "You entered " <<x<< ", wrong guess. Please try again"<<endl; cin >> x; } return 0; }