Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else // if(guess.length() == tobeguessed.length())
- {
- if(guess == tobeguessed)
- {
- cout << "You win!\n";
- break;
- }
- else
- {
- int i;
- int same = 0; // It keeps the count of the matching characters between the two strings.
- int len = guess.length();
- for( i = 0; i < len; i++){
- if(guess[i] == tobeguessed[i]) // if characters are same, increment the count.
- same++;
- }
- cout << "You have " << same << " letters correct\n" << "Incorrect. Guess again: ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement