title: Initializing a const bool array using a function in c++
body: <p>I'm new to c++.
  I'd like to have an const array of a certain length. It is a rather long array so the standard method for initializing constant arrays, namely:</p>
  
  <pre><code>const bool some_array[] = {true, false, true};
  </code></pre>
  
  <p>is impractical. I'd like to initialize a constant array of boolean values. I've tried to implement it like this:</p>
  
  <pre><code>bool* sieve_of_eratosthenes(bool* n, n_length);
  
  int main(){
      bool b[500];
      bool primeList[] = {sieve_of_eratosthenes(b, 500)};
  }
  </code></pre>
  
  <p>this <em>almost</em> works, though it isn't very elegant or space-efficient (i'd be open to comments on how better implement this array). The trouble is, the zeroth element of the returned array, i.e. primeList, is set to true/1, even though I've explicitly set the zeroth element in the boolean array returned by my s_of_e() function to false/zero.</p>
  
  <pre><code>primeList[0] == 1
  </code></pre>
  
  <p>when it should be:</p>
  
  <pre><code>primeList[0] == 0
  </code></pre>
  
  <p>since 0 isn't prime...</p>
  
  <p>Can anyone enlighten me as to why it's doing this?  </p>