how do i fix the following code? i am trying to guess a word and given three hints and trys.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
string word="jane";
string hint[3];
hint[0]="this word is not an object.";
hint[1]="this is a four letter word.";
hint[2]="this is a person's name.";
while ((word!="jane")||(word!="Jane"))
{
hint+=1; //error occurs at this point.i used ++ it doesn't work either.
cout<<"please enter your guess here:\n";
cin>>word;
cout<<hint;
if(hint>3)
{   break;  }
}
Last edited on
Do not do this:
string word="jane";
at the start, or the while loop will never run, because word will be jane from the start.


1
2
3
4
5
6
7
8
9
10
11
index = 0;
while ((word!="jane")&&(word!="Jane"))  // Note &&, NOT ||
{
  cout<<hint[index];
  index++;
  cout<<"please enter your guess here:\n";
  cin>>word;

  if(index>2)
  {   break;  }
}
Last edited on
thank you.
Topic archived. No new replies allowed.