SHARE
TWEET

Untitled

a guest Mar 18th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top