Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. else // if(guess.length() == tobeguessed.length())
  2. {
  3. if(guess == tobeguessed)
  4. {
  5. cout << "You win!\n";
  6. break;
  7. }
  8. else
  9. {
  10. int i;
  11. int same = 0; // It keeps the count of the matching characters between the two strings.
  12. int len = guess.length();
  13. for( i = 0; i < len; i++){
  14. if(guess[i] == tobeguessed[i]) // if characters are same, increment the count.
  15. same++;
  16. }
  17.  
  18. cout << "You have " << same << " letters correct\n" << "Incorrect. Guess again: ";
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement