title: Facing issues while creating value constructor for dynamic array in C++
body: <p>I am writing following code.</p>
  
  <pre><code>BiArray::BiArray(int arr[], int size)  {
      // IMPLEMENT ME
      arrsize_ = size;
      if (arrsize_*LO_THRESHOLD &gt; INITIALCAP)
      {
      capacity_= arrsize_*LO_THRESHOLD;
      } else {
      capacity_= INITIALCAP;
      }
      position_ = ((capacity_ - arrsize_)/2 )-1;
      intrnlArr_ = new int[capacity_];
      for (int i=1; i &lt; arrsize_; i++)
      {
      int a = i-1;
      intrnlArr_[i+position_]= arr[a];
      } 
  }
  </code></pre>
  
  <p>It compiles but when I run a test in the following code I get a segmentation fault.</p>
  
  <p><a href="https://i.stack.imgur.com/mj4IW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mj4IW.png" alt="enter image description here"></a></p>
  
  <pre><code>void BiArrayTester::testValueCtor() {
      funcname_ = "BiArrayTester::testValueCtor";
  
      int arr1[1] = {0};
      BiArray a1(arr1,1);
      if (a1.getSize() != 1 || a1.getCapacity() != INITIALCAP)
          errorOut_("size-1 value constructor incorrect size or capacity",1);
      if (a1[0] != 0) errorOut_("size-1 value constructor incorrect content",2);
  
      int arr2[10] = {0,1,2,3,4,5,6,7,8,9};
      BiArray a2(arr2,10);
      if (a2.getSize() != 10 || a2.getCapacity() != 30)
          errorOut_("value constructor incorrect size or capacity",3);
      for(int i=0;i&lt;10;i++)
          if (a2[i] != i) errorOut_("value constructor incorrect content",4);
  
      passOut_("Tested the value constructor.");
  }
  </code></pre>
  
  <p>Please help me to figure out my fault.</p>