int hangman::checkstatus()
{
for ( int i = 0; i < 5; i++ )
{
if (encryption[i] == '*' )
{
return i;
cout << i;
break;
}
}
if ( i == 4 )
{
cout<<"You win!"<<endl;
}
return 0;
}
Hello guys, this function always returns a '0' and can't figure out why...... Perhaps someone could shread some light into the situation? It's ment to check if an element in the array is = to '*' and if so return that number, else it will assume i == 4 (gone through the array and now hit the end) and return a '0' in which case main as an if statment asking this.........
here is main
int main()
{
char guess;
hangman game1;
cout << "Welcome to hangman alpha ver 1.2 " ;
cout <<"You start off with : "<<game1.getlives() << " lives \n " << endl;
cout << game1.checkstatus();
while((game1.getlives() !=0 ) && (game1.checkstatus() > 0))
{
cout << game1.getencrption() <<endl;
cin >> guess ;
game1.getletter(guess);
}
return 0;
}
well have fun! its been bugging me for hours!