So I'm trying to write a simple program that will prompt a user to input a number between 0-19 and then output the translation of that number in Spanish.
So far I've made a vector of strings and assigned each position in that vector to the corresponding translation.
Ex.
1 2 3 4 5 6 7 8 9 10
vector<string> numbers (20);
numbers.assign (0, "cero");
numbers.assign (1, "uno");
//etc..
numbers.assign (19, "diecinueve");
int num;
cout << //prompt
cin >> num;
cout << "In Spanish that is " << //here's where I have trouble << '.' << endl;
I want to have it so if the user inputs a 3, then it will cout the corresponding string for that position. I just don't know exactly how to do that, or if it's even possible.
I would have asked you to use std::map but since it looks like you're still trying to get the hang of C++, so I'll use a very simple method, std::vector, right? :) Store all the 20 spanish words in a vector of strings, ask the user to input a value, make sure the value is lesser than 20 and greater than or equals 0. Simply access the vector with the input.
Thank you so much OxBADC0DE, you gave me a little laugh also.
I ended up doing it a longer way after I found out that vector.assign was not doing what I wanted it to do lol
I ended up doing multiple push_back statements, which is dumb in hindsight.
You're code is so much shorter than mine because of that, but I need to look at some of the things you used and figure out what exactly they're doing.
But thank you so much for your help! It's extremely appreciated.