title: Reinitialize array in while-loop
body: <p>Let say I have the following array</p>
  
  <pre><code> char ch[1000];
  </code></pre>
  
  <p>And I initialize this char</p>
  
  <pre><code>for (int i = 0; i &lt; 1000; i++) {
     ch[i] = 0;
  } 
  </code></pre>
  
  <p>And then I want to use this array in a while loop</p>
  
  <pre><code> bool active = true;
   int i = 0;
   while(active) {
  
  
       ch[i] = ....... // fill the array with certain ashii 
  
       // code 
       strcpy(string, ch); // after this - I may go back to the top of the loop and startover   
  
       i++;
   }
  </code></pre>
  
  <p>The loop does not really look like this in reality - but this is only schematic. The issue is here (and my question) - IF I now want to use this char-array again in the loop - that is go to the top of the while loop and fill the char-variable with new characters, what is the best way to empty the array from old characters.</p>
  
  <p>1) change the code so that I declare this buffer WITHIN the while-loop</p>
  
  <p>It does not seem efficient to reinitialize it again with a for loop as I did outside the loop</p>
  
  <pre><code> for (int i = 0; i &lt; 1000; i++) {
     ch[i] = 0;
   }     
  </code></pre>
  
  <p>This approach seem to demand a lot of cpu-instructions</p>
  
  <p>Are there better ways to do this?</p>