title: Password Prompt using For Loop (C++)
body: <p>I am having a small problem in my code from a practice problem in Jumping into C++ by Alex Allain using a For Loop below. </p>
  
  <p><strong>Code Below</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main ()
  {
      string password;
      for ( int i = 5; i&gt;=0; i-- ) {
          cout &lt;&lt; "Please enter your password you have " &lt;&lt; i &lt;&lt; " attempts remaining: ";
          cin &gt;&gt; password;
      }
      if ( password == "Kent" ) {
          cout &lt;&lt; " Password is correct.";
          break;
      } else {
          i--;
          cout &lt;&lt; i &lt;&lt; " attempts remaining." &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I am getting this error at the break statement below in the build messages {using CodeBlocks}</p>
  
  <pre><code>C:\Users\Documents\Jumping into C++\src\practice 4 (chapter 5 
  variant).cpp|23|error: name lookup of 'i' changed for ISO 'for' scoping 
  [-fpermissive]|
  </code></pre>
  
  <p>I have done this same exact code using a while loop without a problem but when I use a For Loop the compiler goes on a witch hunt.. any help is appreciated :)</p>