title: C++ Dynamic Array: A value of type "void" cannot be used to initialize an entity of type "int"
body: <p>I am working on a C++ project for school in which the program will read in a list of numbers from a text file, store them in a dynamic array, then print them out to another text file. To be honest I'm a little lost with the pointers in this, and I am getting the error "A value of type "void" cannot be used to initialize an entity of type "int"" in my main source file. </p>
  
  <p>Main.cpp (this is where I'm getting the error):</p>
  
  <pre><code>#include "dynamic.h"
  
  int main
  {
      readDynamicData("input.txt","output.txt");
  }
  </code></pre>
  
  <p>dynamic.cpp (the skeleton for the program):</p>
  
  <pre><code>#include "dynamic.h"
  
  
  void readDynamicData(string input, string output)
  {
      DynamicArray da; //struct in the header file
      da.count = 0;
      da.size = 5; //initial array size of 5
  
      int *temp = da.theArray;
      da.theArray = new int[da.size];
  
  
      ifstream in(input);
      ofstream out(output);
  
      in &gt;&gt; da.number; //prime read
      while (!in.fail())
      {
          if (da.count &lt; da.size)
          {
              da.theArray[da.count] = da.number;
              da.count++;
              in &gt;&gt; da.number; //reprime
          }
          else grow; //if there are more numbers than the array size, grow the array
      }
  
  
      out &lt;&lt; "Size: " &lt;&lt; da.size &lt;&lt; endl;
      out &lt;&lt; "Count: " &lt;&lt; da.count &lt;&lt; endl;
      out &lt;&lt; "Data:" &lt;&lt; endl;
      for (int i = 0; i &lt; da.size; i++)
          out &lt;&lt; da.theArray[i];
  
      in.close();
      out.close();
  
      delete[] temp;
  }
  
  
  void grow(DynamicArray &amp;da) //this portion was given to us
  {
      int *temp = da.theArray;
      da.theArray = new int[da.size * 2];
      for (int i = 0; i&lt;da.size; i++)
          da.theArray[i] = temp[i];
      delete[] temp;
      da.size = da.size * 2;
  }
  </code></pre>
  
  <p>and dynamic.h, the header file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #ifndef _DynamicArray_
  #define _DynamicArray_
  
  
  using namespace std;
  
  void readDynamicData(string input, string output);
  
  struct DynamicArray
  {
      int *theArray;
      int count;
      int size;
      int number;
  };
  
  void grow(DynamicArray &amp;da);
  
  #endif
  </code></pre>