title: How to set up a variable length array for a prime-sieve algorithm in C?
body: <p>I'm completely new to C, only really having had experience with Python in the past, so please forgive my ignorance here. </p>
  
  <p>I'm trying to implement the prime-sieve algorithm of Eratosthenes in C. This algorithm recursively discards all multiples of a given number until the last number you wish to know is found. Specifically, the program will have an input <strong>n</strong>, and will output all prime numbers smaller than <strong>n</strong>.</p>
  
  <p>To achieve this, I thought to create an array of length <strong>n</strong> and recursively cycle over this array, discarding integers I no longer care about (by changing them to 0).</p>
  
  <p>The problem I found however, is that c does not allow for an array of variable length. I thought I outsmarted this rule for a little bit by doing this trick:</p>
  
  <pre><code>void Sieve(int n) {
      int prime[n+1];
  }
  </code></pre>
  
  <p>But sadly, even variables given to functions aren't okay.</p>
  
  <p>Hence my question: How can I initiate such an array in C?</p>