title: Using an array to filter through an array
body: <p>I have an array of chars (data[]) and I need to filter out only those whose index is a prime number. The array of chars (data[]) can contain up to 1000*1000*3 elements. Now, I get a list of prime numbers from 2 to 1000*1000*3 from a function and store it in a globally defined array (primes[]). How can I use it to filter out the data[] array? This is my code so far:</p>
  
  <pre><code>int k = 0;
  char filtered[] = {0}; // I don't know what to put between the [ ] brackets.
  for(int i = 0; i &lt; ???; i++) // what do I put instead of ???
  {
      filtered[i] = data[primes[k]];
      k++
  }
  
  for(int i = 0; i &lt; len; i++)
      printf("%c\n", filtered[i]);
  </code></pre>
  
  <p>But this code obviously gives me SIGSEGV. Could you please help me fixing this?</p>