using enum indexed array

Oct 15, 2015 at 4:26pm
I'm attempting a program with an array indexed by and enum. I will need user input to determine which part of the multiple dimensioned array to use. My problem is I can not figure out what to use to grab the user input. We have not covered maps and pointers yet and the instructor indicated we will need to use the #cctype header. For the life of me I can not make the connection here. I feel if I just had an idea of how to grab the input I could finish the rest of the program alone. Any help would be greatly appreciated. I have other snippets of code for other functions but this is the snippet that applies to my question.

//preprocessor commands
# include <iostream>
# include <iomanip>
# include <cctype>
# include <cstring>

using namespace std;
//Const Variables declared
const int NUM_OF_ROWS=4;
const int NUM_OF_COLUMNS=4;
enum curFrom{USD,INR,GBP,EUR};
double const conversionTable[NUM_OF_ROWS][NUM_OF_COLUMNS]={{1.00,66.60,0.89,0.65},
{.015,1.0,0.014,0.010},
{1.55,99.42,1.35,1.0},
{1.12,73.70,1.0,0.74}};

double currency;
int main()
{
cout<<"Please enter the currency to convert from.";


}
Oct 15, 2015 at 4:52pm
Here's an article I wrote about the proper way to handle user input:
http://www.LB-Stuff.com/user-input
See if it helps.
Oct 15, 2015 at 8:24pm
Thank you. I understand the part about getline from input. We have not been introduced to sstream yet so I'm not sure how to make the while loop stop. I see from the article that you use it to assign the input to line to stop the loop. However, it's not something I can use yet. I'm not sure what to set as the loop control once I get the enum value from the user. Does that make sense? I've been fiddling with this assignment for days and I am not sure if I make sense anymore. Also, your article was excellent and clearly stated esp for a beginner like myself.
Oct 15, 2015 at 8:36pm
Don't be afraid to use something you haven't learned about. Unless your professor is a bad teacher and specifically forbids it, go ahead and use the information you learn on your own.
Oct 15, 2015 at 9:00pm
My fear is that he may think that I've "stolen" the code. However, if I understand it I would hope that would not be the case. Thank you,again, for your help.
Topic archived. No new replies allowed.