title: How do i take integers from a file and place them in an int vector?
body: <p>I am trying to take a text file and take the integers inside the file and transfer them into a vector in which can be read into different functions. </p>
  
  <p>This is what i have so far:</p>
  
  <pre><code>int main(int argc, char *argv[] )
  {
  vector&lt;int&gt; buff;
  argv[1] = "input_24_0.txt";
  
  if (argc &lt; 2)
  {
      std::cout &lt;&lt; "usage: " &lt;&lt; argv[0] &lt;&lt; " &lt;filename&gt;\n";
      return 2;
  }
  std::ifstream fin(argv[1]);
  if (fin)
  {
      std::stringstream ss;
      // this copies the entire contents of the file into the string stream
      ss &lt;&lt; fin.rdbuf();
      // get the string out of the string stream
      std::string contents = ss.str();
      std::cout &lt;&lt; contents;
      // construct the vector from the string.
      std::vector&lt;int&gt; buff(contents.begin(), contents.end());
  }
  else 
  {
      std::cout &lt;&lt; "Couldn't open " &lt;&lt; argv[1] &lt;&lt; "\n";
      return 1;
  }
  
  clock_t t1, t2, t3, t4;
  
  int maxSum;
  
  t1 = clock();
  maxSum = maxSubSum1(buff);
  cout &lt;&lt; "MaxSubSum1 is " &lt;&lt;  maxSum &lt;&lt; endl;
  cout &lt;&lt; double( clock() - t1 )
  / (double)CLOCKS_PER_SEC&lt;&lt; " seconds." &lt;&lt; endl;
  t1 = clock() - t1;
  
  t2 = clock();
  maxSum = maxSubSum2( buff );
  cout &lt;&lt; "MaxSubSum2 is " &lt;&lt;  maxSum &lt;&lt; endl;
  cout &lt;&lt; double( clock() - t2)
  / (double)CLOCKS_PER_SEC&lt;&lt; " seconds." &lt;&lt; endl;
  t2 = clock() - t2;
  
  t3 = clock();
  maxSum = maxSubSum3(buff );
  cout &lt;&lt; "MaxSubSum3 is " &lt;&lt;  maxSum &lt;&lt; endl;
  cout &lt;&lt; double( clock() - t3 )
  / (double)CLOCKS_PER_SEC&lt;&lt; " seconds." &lt;&lt; endl;
  t3 = clock() - t3;
  
  t4 = clock();
  maxSum = maxSubSum4( buff );
  cout &lt;&lt; "MaxSubSum4 is " &lt;&lt;  maxSum &lt;&lt; endl;
  cout &lt;&lt; double( clock() - t4 )
  / (double)CLOCKS_PER_SEC&lt;&lt; " seconds." &lt;&lt; endl;
  t4 = clock() - t4;
  
  system("pause");
  
  return 0;
   }
  </code></pre>