How would I 'point' (deference) a pointer to something that was selected in a switch statement? I created a pointer and a switch statement. The user selects a choice. How do I make the pointer point to what was selected? No, I don't want an easier way of doing this, I want to know how I would do it with a pointer. Here is what I have so far:
As for your question you could use an array of the type int
1 2 3 4 5 6 7 8 9 10
const size_t N = 5;
int a[N];
// here you fill the array
cout << "Enter number to point to: " << endl;
cin >> pt;
if ( 0 < pt && pt < 6 ) std::cout << a[pt-1] << std::endl;
else std::cout << "you have enetered incorrect number\n";