title: Getting "vector subscript out of range" error
body: <p>I'm currently trying to get "variadic functions" down and just trying to load 4 names in a string vector and then print them out.  When I do this with 'int' type and use numbers, it works fine, but when I use a string vector I get the error. </p>
  
  <pre><code>#include "stdafx.h"
  #include&lt;cstdio&gt;
  #include&lt;cstdarg&gt;
  #include&lt;string&gt;
  #include&lt;vector&gt;
  #include&lt;iostream&gt;
  using namespace std;
  
  
  
  int count;
  
  vector&lt;string&gt; namesVector;
  
  void names(int count, ...)
  {
      va_list namesList;
  
      int i; // for loop
  
      va_start(namesList, count);
  
      for (i = 0; i &lt; count; i++)
      {
          string currentElement;
          currentElement = va_arg(namesList, string);
  
          namesVector[i] = currentElement;
  
      }
  
      va_end(namesList);
  }
  
  
  int main()
  {
      int nameCount = 4;
  
      names(nameCount,"jon", "maggie", "joan", "alfred");
  
      for (int i = 0; i &lt; nameCount; i++)
      {
          cout &lt;&lt; "Name at element " &lt;&lt; i &lt;&lt; " is: " &lt;&lt; namesVector[i] &lt;&lt; endl;
      }
  
  }
  </code></pre>