I\'m trying to create something in C++, and I\'m in need of additional help. The
ID: 639395 • Letter: I
Question
I'm trying to create something in C++, and I'm in need of additional help.
The program that I've entered below should receive user's input for letters (no more than 10, no less than three), and place them into an array.
The program will then read a file into an array. The program will compare the two arrays, printing out any combination of the letters that is found in the txt file array (the text file contains a list of words that have only three letters).
Here is what I have so far. I will award as many points as possible ONLY to those who actually answer my question, and provide real help. Points will also be given for help on aspects that should be addressed in the program. I know there are some pointer issues here, at least. In short, it's help I need.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void processUserInput()
{
//read and print
cout<<"Please enter UP TO 10 LOWERCASE letters"<<endl;
cout<<"With a MINIMUM of 3 LETTERS"<<endl;
cout<<"Enter a '-' to stop reading letters if there are less than 10"<<endl;
char letters[10];
for (int w=0;w<10;w++)
{
cout<<"Letter #"<<w<<": "<<endl;
cin>>letters[w];
}
for(int l = 0; l < letters.length(); l++)
{
letters[l] = tolower(s[l]);
}
if (letters.size()>=3 && letters.size()<=10 && letters()=='-')
{
cout<<"You entered: "<<inputLetters<<endl;
}
else if (inputLetters.size()<3 || inputLetters.size()>10)
{
cout<<"Please enter no less than three, and no more than ten lowercase letters"<<endl;
}
findWords();
}
void findWords()
{
//this finds words
char &letters[10];
readLegalWords();
}
void readLegalWords()
{
string legalWords[908];
ifstream inputFile;
inputFile.open("words.txt");
for (int z=0; z<908; z++)
{
inputFile >> legalWords[z];
}
inputFile.close();
comparison();
}
void comparison(char letters[],string legalWords[])
//this should compare the two, and print out the words that match
{
for (int doingIt1=0;doingIt1<908;doingIt1++)
{
if letters[doingIt1]=legalWords[doingIt1] &&
if letters[doingIt1+1]==legalWords[doingIt1+1]&&
if letters[doingIt1+2]==legalWords[doingIt1+2]
{
cout<<Legal Words are:<<endl;
cout<<letters[doingIt1]<<letters[doingIt1+1]<<letters[doingIt1+2]
}
}
}
void menu()
{
//the main menu
char ch;
cout<<"Enter your choice:"<<endl;
cout<<"(F)ind words"<<endl;
cout<<"or"<<endl;
cout<<"(Q)uit"<<endl;
cout<<"CHOICE: "<<endl;
cin>>ch;
//menu (switch)
switch(ch)
{
case 'f':
case 'F':processUserInput();
break;
case 'q':
case 'Q':cout<<"EXITING PROGRAM."<<endl;
system("PAUSE");
return 0;
default: cout<<"Invalid Entry. Please try again"<<endl;
break;
}
}
int main()
{
//main
cout<<"MAIN MENU IS BELOW"<<endl;
menu();
system ("PAUSE");
return 0;
}