title: Function fills vector yet it becomes empty at some point.
body: <p>I have encountered a strange problem. I am attempting to fill a vector with one function then output it with another. The vector appears empty even after the function has been called though, and I believe it is filling it correctly. Here is my code so far. The result is </p>
  
  <p>"Enter the input file name in.txt
  Search in vector
  terminate called after throwing an instance of 'std::out_of_range'
    what():  vector::_M_range_check
  Aborted (core dumped)
  " </p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;cassert&gt;
  
      #include&lt;vector&gt;
      #include "ArrayUtilities.h"
  
  
      using namespace std;
  
      void fillArray(istream&amp; io, std::vector&lt;int&gt; a, int&amp; actualSize)
      {
         int temp,i=0;
         io&gt;&gt;temp;
         while (temp!=-999)
         {
         a.push_back(temp);
             io&gt;&gt;temp;
             i++;
         }
  
         actualSize=i;
      }
  
  
  
      void outputArray(ostream&amp; os,
              std::vector&lt;int&gt; a,
              const int actualSize,
              const string&amp; info )
      {
  os&lt;&lt;info&lt;&lt;"\n";
  for (int w=0;w&lt;actualSize;++w)
  {
      os&lt;&lt; a.at(w)&lt;&lt;" ";
  
  }
  os&lt;&lt;"\n";
  }
  </code></pre>
  
  <p>int main()
  {</p>
  
  <pre><code>int actualSize;
  string fileName;
  string info;
  
  
  std::vector&lt;int&gt; a;
  cout &lt;&lt; "Enter the input file name ";
  cin  &gt;&gt; fileName;
  ifstream inData;
  ofstream outData;
  inData.open(fileName.c_str());
  outData.open("out.txt");
  int searchItem;
  inData&gt;&gt;info;
  inData&gt;&gt;searchItem;
  fillArray  (inData,  a, actualSize);
  cout   &lt;&lt;"Search in vector\n";
  outData&lt;&lt;"Search in vector\n";
      outputArray(outData, a, actualSize, info);
  outputArray(cout,    a, actualSize, info);
  //sequential search
  int position;
  position=seqSearch(a,actualSize,searchItem);
  if (position &gt; 0)
      {
          cout    &lt;&lt; "Sequential Search: SearchItem "
                  &lt;&lt; searchItem
                  &lt;&lt; " is on position "
                  &lt;&lt; position
                  &lt;&lt; "\n";
          outData &lt;&lt; "Sequential Search: SearchItem "
                  &lt;&lt; searchItem
                  &lt;&lt; " is on position "
                  &lt;&lt; position
                  &lt;&lt; "\n";
      }
      else
      {
          cout    &lt;&lt; "Sequential Search: SearchItem "
                  &lt;&lt; searchItem
                  &lt;&lt; " is not in the list\n";
          outData &lt;&lt; "Sequential Search: SearchItem "
                  &lt;&lt; searchItem
                  &lt;&lt; " is not in the list\n";
      }
  </code></pre>
  
  <p>thank you for the help</p>