title: Vector/Array problems, cannot assign index to variable/cannot use variable as the array size(indexes) C++
body: <p>Okay so I am trying to convert integers to binary through this convert function, but I am having some trouble with the array/vector use in it. I previously had this working using an array, but I started getting errors on it. I put the array (commented out) I originally used below the vector I am using now. I switched to a vector because it seemed like, from the research I've done, it would be better.</p>
  <p>I am getting an error on <code>tempArray[i] = remainder;</code> in the for loop.</p>
  <p>The error says:</p>
  <blockquote>
  <p>Error  2   error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)`</p>
  </blockquote>
  <p>I read something about overloading, but do not really know what that is.</p>
  <p>When I did an array I was getting these three errors on digits <code>int tempArray[digits];</code> which I put as the index (For the array just comment out the vector and use the array already commented out):</p>
  <blockquote>
  <p>Error  1   error C2057: expected constant expression</p>
  <p>Error  2   error C2466: cannot allocate an array of constant size 0</p>
  <p>Error  3   error C2133: 'tempArray' : unknown size</p>
  </blockquote>
  <p>Lastly, I just switched from using Sublime Text 3 and Cygwin as my compiler to using Visual Studios so I do not know if that may have something to do with it.</p>
  <pre><code>char* convert(int palindrome)
  {
      int remainder, digits = 0, dividend = palindrome;
  
      while (dividend != 0)
      {
      dividend = dividend / 2;
      digits++;   //5 digits, Johns Computer
      }
  
      std::cout &lt;&lt; &quot;Digits: &quot; &lt;&lt; digits;
  
      std::vector&lt;int&gt;* tempArray = new std::vector&lt;int&gt;[digits]; // vector
      //int tempArray[digits]; using an array
  
      dividend = palindrome;
  
      for (int i = digits - 1; i &gt;= 0; i--)
      {
      remainder = dividend % 2;
      tempArray[i] = remainder;
      dividend = dividend / 2;
      // cout &lt;&lt; array[i];
      }
  
      // cout &lt;&lt; setw(3) &lt;&lt; palindrome &lt;&lt; &quot; in binary is&quot; &lt;&lt; setw(3);
  
      for (int j = 0; j &lt; digits; j++)
      {
          //  cout &lt;&lt; array[j];
      }
  
      if (palindrome == 0)
      cout &lt;&lt; 0;
      cout &lt;&lt; endl;
  
      //int *pDriveArray = array[digits];
      //return readDrives(array, digits);
  
      return 0;
  
  }
  
  
  int main() {
  
      char *currDrives = convert(GetLogicalDrives());
  
      cin.get();
  
      return 0;
  
  }
  </code></pre>
  <p>Edit: Fixed the issue with help below. At the end of the convert function, I have <code>return readDrives(tempArray, digits);</code> and I am getting an error on tempArray. Whats the proper way to return a vector?</p>