title: Password String compare [C++]
body: <p>Trying to do a password validation method in order to allow a user to use my program.</p>
  
  <p>I was wondering how would someone would implement such a code that allows the program to compare two strings, going down all the letters and numbers to make sure everything matches, and then allows a user to access program controls after successfully entering in a password.</p>
  
  <p>So, for example, if the password is "h3llo" and someone typed in "he" the program will output an error message saying that the password is incorrect.</p>
  
  <p>Here is what I started with:</p>
  
  <pre><code>void checkPassword() {
      cout &lt;&lt; "Enter password: ";
      string password = "H3110W0r1d";
      int length = password.length();
      int i;
      string input;
      cin &gt;&gt; input;
  
      for (i = 0; i &lt; length; i ++) {
          if ((input[i].compare(length[i]))) == 1) {
              if ((input[i].compare(length[i])) == 0) {
                  cout &lt;&lt; "Error! Wrong password!";
              } else {
      cout &lt;&lt; "Welcome!";
      }
  }
  </code></pre>
  
  <p>I've tried so many different ways, however, I can't seem to get it working. Any help on what I am doing wrong?</p>