What my program is supposed to do is generate a random array of characters that is 6 letter. What the user then does is using the letters given try to make words(you can add extra vowels for -1 point each time). So far i have a grip on all of it besides that part of comparing the 2 arrays.
In example if a s r t u i are my random letters in an array
I want ask the user for word... if he/she inputs art as a word, how do i compare the 2 to see if the letters match w/o extra vowels?
char array[6] = {'a', 's', 'r', 't', 'u', 'i'}; // Pretend this was determined randomly
char array2[6] = array; // Copy random array
char word[6]; // Designed for user word
int count = 0;
char temp;
while(true){
cin >> temp;
for(int i = 0; i < 6; i++0{
if(temp == array2[i]){
// Adds the input letter to the user array, then increments the counter
word[count++] = temp;
array2[i] = '*'; // Sets the used letter to an asterisk (deletes it)
break;
}
else cout << "Letter not available\n" << endl;
}
if(count == 6) break; // Made a six-letter word. Need to reset count to 0
/*
else if(/*User presses enter/*) break;
*/
}
int main()
{
srand(time(0));
char my_array[8];
char word[10];
int score;
welcome();
random_letters(my_array);
output(my_array, word);
players_words();
match_word(score, word, my_array);
//input_word();
}
void welcome()
{
cout<< endl<< endl<< endl<< endl<< endl <<endl <<endl <<endl;
cout << "Welcome, thank you for choosing to play, in this game you will be provided with"
<< "6 letters. Your goal is to make as many words with the 6 letters. For words 2-3"
<< endl<< " letters you get 2 points, for words 4-5 letters you get 3 points, for words 6 or"
<<" more you get 4 points. You may add vowels not in the list, costing 1 point. To win "
<<"you " << endl <<"need 20 points, you lose if you have a negatie score."
<< endl <<endl <<endl <<endl <<endl <<endl <<endl;
}
I wouldn't want someone to do it for me haha!! Then i don't learn!
I understood what your program was doing and i tried my best to implement it.... Still not working 100%
This is the checking part
bool found = false; //setting to false to have the condition set it to go
// through the for loop
//this for loop goes through the word[] array
for(int j = 0; j < strlen(word); ++j)
{
bool match = true; //set this to true because the cs tutor said...
//didn't understand why
//this for loop goes through the letters of my_array
// did not finish this section :/ had to go to work so submitting now
for (int i = 0; i < size; ++i)
{
if(my_array[i] != word[j]) // if the condition is met match is false, otherwise match is true
{
match = false;
}
else{
match = true;
}
//sets found to true is match is true
} if(match = true){
found = true;
this is my scoring part
void point_give(int & score, char word[], int word_size){
I'm re-writing your post formatted as code so I can look through it easier.
Tip: put
[*code*]
//code here
[*/code*]
at the beginning and end of your copied code without the asterisks to display it as it would in your IDE.
//setting to false to have the condition set it to go through the for loop
bool found = false;
//this for loop goes through the word[] array
for(int j = 0; j < strlen(word); ++j){
//set this to true because the cs tutor said... didn't understand why
bool match = true;
//this for loop goes through the letters of my_array
// did not finish this section :/ had to go to work so submitting now
for (int i = 0; i < size; ++i){
// if the condition is met match is false, otherwise match is true
if(my_array[i] != word[j]){
match = false;
}
else{
match = true;
}
}
//sets found to true is match is true
if(match == true){
found = true;
}
//this is my scoring part
void point_give(int & score, char word[], int word_size){
word_size = strlen(word);
if(word_size == 2 || word_size == 3){
score += 2;
}
elseif(word_size == 4 || word_size == 5){
score +=3;
}
elseif(word_size >= 6){
score +=4;
}
}
Sorry man. I want to help you, but I just can't see what's going on here. I don't really know what you're looking for. But feel free to incorporate that while loop from earlier.