+ 1

User Select from Array (C++)

I used to know how this worked but have completely forgotten. Here is an attempt at code allowing a user to select from an array. But I get the following error: "reference to overloaded function could not be resolved; did you mean to call it?|" #include <iostream> using namespace std; int main() { int selectPlant; string plant[] = {"Etymology and terminology", "Description", "Taxonomy", "Cultivation", "Nutrition", "Uses", "Culture"}; cout << "Please select an item from the Plant table (0-6): "; cin >> selectPlant >> endl; cout << plant[selectPlant] << endl; return 0; }

3rd May 2018, 3:02 PM
Michelle
Michelle - avatar
2 Réponses
+ 7
Remove the endl on the cin line
3rd May 2018, 3:24 PM
jay
jay - avatar
+ 1
Thank you Jay! I can't imagine why I thought I needed that there.
3rd May 2018, 5:50 PM
Michelle
Michelle - avatar