just start first year uni , not speak good english now finish project in 2 days , please need help widh this . I need to make c++ programme to do
1st - A function loads a dictionary file of English words into the program .
2nd - The user is asked to enter 8 selections of vowel or consonant in turn, and can see the letters chosen at random at each step
3rd - then search the dictionary for the word or words with longest matching set of letter
4- display word or words
i do little work and wrote this but dont know what next or its right?
#include<fstream>
#include<iostream>
#include<string>
#include"iolib.h"
#include<time.h>
#include<algorithm>
using namespace std;
int main()
{
char input;
ifstream inFile( "C:\\Users\\jo\\Desktop\\FPJ\\Dictionary.txt", ios::in);
if (inFile.is_open())
{
cout << "Dictionary Added Successfully " <<endl ;
inFile.close();
}
else cout << "Unable to open file";
cout << endl << "
Welcome To My Game : "<< endl;
string userinput[8];
for (int i = 0; i < 8; i++)
{
cout << "Enter ONE Consonant or vowel : " << endl;
cin >> userinput[i];
cout << " You entered : " << userinput[i]<< endl;
} ;
Someone please help me width this my head will explode
You should split the reading and writing into functions that way you can see what went wrong and it'll look nicer and more clear.
if you put everything in the main it will be very hard to see where the issue is
Also, if the user is asked to enter 8 selections of vowels or constants, these are all single chars, so there is no use for an array of strings, it will take up unnecessary space
You also don't need include <time>
Your for loop is constructed correctly, but it is good practice to use a function to this and pass the array of chars as reference like:
should me just use string ? or char? not sure
and program be able to take input and show entered letter when asking for next letter input ?
how?
how to store inputs and then retrieve at once to search dictionary
sorry me clueless about above task.
Just started month ago dont have good grasp on this if you could solve these problem me be really gratefull, I struggle because i transfer from other course and now have homework.
Tried to learn tutorials but too many to read short time
thanks
made changes below , is this better ??
#include<fstream>
#include<iostream>
#include<string>
#include"iolib.h"
#include<algorithm>
using namespace std;
Hi thanks for help finally managed to get it all working , except for one problem
I am using arrays to save user input of a total of eight letter . The program asks for them one by one example
Enter a random vowel or consonant: u
You have entered: u
Enter a random vowel or consonant: run
You have entered: ur
Enter a random vowel or consonant: You have entered: uru
Enter a random vowel or consonant: You have entered: urun
-----------
as you can see above its allowing entry of more than one letter, i want to restrict to one letter input only