word guessing game Random generator problem

i am currently working on word guessing game but my random word generator doesn't seem to work properly in the loop. would be nice if someone could look at my code and and give me some tips or pointers :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include "conio.h"

using namespace std;
const int Max_Points=5;
int letterFill (char, string, string&);
string words_rand ();

int main ()
{
  

char letter;
int Points=0;
string word;
string words[] ={"skyrim","warhammer","dune"};
//******Random*******

//srand(time(0));
//int i=0;
//i=rand()% 3;


//******Maska*******

//******Vieta Jusu reklamai*******




word = words_rand ();
string unknown(word.length(),'.');

do 
{
// word = words_rand ();
//string unknown(word.length(),'.');  
   cout << "\n" << unknown;
   cout << "\nMini burtu: ";

   letter = getch();
   system("cls");

   if (letterFill(letter, word, unknown)==0)
   {
   cout << endl << "Nav tada burta:" << endl;
   Points++;
   }
   else
   {
   cout << endl << "Ir tads burts saja spele: " << endl;
   }
   cout << "Tev ir: " <<  Points;
   cout << " punkti." << endl;
   if (word==unknown)
   {
   cout << word << endl;
   cout << "Uzmineji!";
   }

   if(Points == Max_Points || letter == '0' )
   {   
   cout << "\nGAME OVER" << endl;
   cout << "Vards : " << word << endl;
   system("pause");
   return 0;
   }
  
}
   while (Points < Max_Points);
 
   cin.ignore();
   cin.get();
   system("pause");
   return 0;
}

string words_rand ()
{
string word;
string words[] ={"skyrim","warhammer","dune"};
//******Random*******
srand(time(0));
int i=rand()% 3;
word = words[i];
return word;    
}

int letterFill (char guess, string secretword, string &guessword)
{
    int i;
    int matches=0;
    int len=secretword.length();
    for (i = 0; i< len; i++)
    {
   if (guess == guessword[i])
   return 0;
   if (guess == secretword[i])
   {
   guessword[i] = guess;
   matches++;
   }
   }
return matches;
}
anyone? :)
hey VaMpZzz please help me.please solve this question of c++.please please...thankyou

Q. Write a program that performs the following operations on strings:
• Use a function count(char[]) to count the number of no. of vowels (uppercase & lowercase) & the no. of consonant ( uppercase & lowercase) no. of spaces, no. words, no. of digits and the no. of special characters in the string.
• Use a function change() to change the case of characters of a string.
• Uses a function reverse() to find the reverse of a string.
• Uses a function replace() to replace every space in a string with a hyphen.
• Uses a function check () to check whether a character is present in the string or not. The function should take in the string and the character to be searched and then display appropriate message.
• Uses a function revword() to reverse each word of the string.
Last edited on
Topic archived. No new replies allowed.