I created an english-spanish translator and need to make it translate spanish to english from an input file. I used vectors to read the english translations from the file i have which is called dictionary. So an example of the dictionary file would be black, negro blue, azul green, verde
and so on.
heres a link to the dictionary file I have set up
I prompt the user to input the word and it will translate. I figured out how to use the english-spanish vector first. I tried to switch around my for loop thinking it would work but I realize my vector for loop doesn't read right to left. So how do you make a vector read right to left from an input file? I implemented a boolean so when the word or translation has been found it will cout it, but since it doesn't read right to left it wont cout. Need help thanks.
To view my full program to test it heres a link:
below is the code block for the vector that needs to be read right to left /////////////////////
void spanish()
{
ifstream fin;
vector <string> eng;
vector <string> span;
string words,temp;
bool FOUND = 0;
fin.open("dictionary.txt");
if (fin.fail())
{
cout << "Failed";
exit(1);
}
do{
getline(fin, words);
eng.push_back(words);
getline(fin, words, ',');
span.push_back(words);
}while (!fin.eof());
cout << " Spanish-English Now type in a Word you want to translate\n";
cin >> words;
for (int i=0; i < words.length(); i++)
words[i]= toupper(words[i]);
cout << "you entered " << words << endl;
for (unsigned int i=0; i<span.size(); i++)
{
if (span[i]==words)
{
cout << "Spanish translation is \n" << eng[i] << endl;
FOUND = 1;
}
if (FOUND)
break;
}
/////////////////////////////////////////// THIS VECTOR NEEDS TO READ RIGHT TO LEFT!!!
fin.close();
}