Hi everybody! This is my first time posting in this forum and have read the rules (plus ive been on other forums so im aware of general standards) but if im breaking one please let me know because its unintentional. so heres my problem. im learning elvish but there are a lot of words so i decided to make a program where i can insert words in both english and elvish and then when i need to look up a word i can type it in and find the corresponding word in the other language. i put database in quotes because its in corresponding text files because it was taking too long to install mysql then learn how to interface with it in c++. heres my code:
here is what happens when i run it:
it skips input on the common word
also im using xcode
#include <iostream>
#include <map>
#include <string>
#include <cstdlib>
#include <fstream>
using namespace std;
typedef map<string, string> table;
void addWords();
void findWords();
void listWords();
void help();
int main()
{
string input;
while(true)
{
cout<<"Action: ";
getline(cin, input);
if(input == "add words")
addWords();
else if(input == "find specific words")
findWords();
else if(input == "see all words")
listWords();
else if(input == "help")
help();
else if(input == "exit")
exit(1);
else
cout<<"error: invalid action. type help for help"<< endl;
}
}
void addWords()
{
string input;
char answer;
fstream file;
do
{
cout<<"elvish word: ";
getline(cin, input);
cout<<"So, is \""<< input <<"\" correct (y/n)? ";
cin>> answer;
if(answer == 'y')
break;
else if(answer == 'n')
continue;
else
cout<<"error: invalid input option"<< endl;
}while(true);
file.open("/Users/Shared/elfWordList.txt");
file<< input << endl;
file.close();
do
{
cout<<"common word: ";
getline(cin, input);
cout<<"So, is \""<< input <<"\" correct (y/n)? ";
cin>> answer;
if(answer == 'y')
break;
else if(answer == 'n')
continue;
else
cout<<"error: invalid input option"<< endl;
}while(true);
file.open("/Users/Shared/commonWordList.txt");
file<< input << endl;
file.close();
}
void findWords()
{
}
void listWords()
{
}
here is what happens when i run it:
Action: add words elvish word: mellon So, is "mellon" correct (y/n)? y common word: So, is "" correct (y/n)?
it skips input on the common word
also im using xcode