title: Initializing variable in loop
body: <p>Im trying to figure out what is the best practice when initializing certain variables...
  My code looks like this at the moment:</p>
  
  <pre><code>int nHexCount = 0;
  int prevState = sc.state;
  
  bool bOnlySpaces = true;
  bool bIsValidLabel = true;
  bool bIsHotstring = false;
  bool bIsValidName = true;
  bool bIsValidExpStart = false;                         
  
  bool fInExpression = false;
  bool fInStringBlock = (sc.state == SCE_AHKL_STRINGOPTS || sc.state == SCE_AHKL_STRINGBLOCK);
  
  for (; sc.More(); sc.Forward()) {
  
      if (sc.atLineStart) {
          if (!fInStringBlock &amp;&amp; sc.state != SCE_AHKL_COMMENTBLOCK)
              sc.SetState(SCE_AHKL_DEFAULT);
  
          // Reset Status
          prevState = sc.state;
  
          bOnlySpaces = true;
          bIsValidLabel = true;
          bIsHotstring = false;
          bIsValidName = true;
          bIsValidExpStart = false;
  
          fInExpression = false;
      }
  
  ...
  </code></pre>
  
  <p>So as you can see most of these variables are reset each time my program finds a new line in the edit component i am working on...</p>
  
  <p>The question would be: </p>
  
  <p><strong>Is it better programming practice declaring and initializing all those variables inside the for loop or should i leave it like it is at the moment?</strong></p>