#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

New Topic/Question
Reply



MultiQuote




|