title: C++ vector memory access issue
body: <p>I have a vector with a list of commands as shown below:</p>
  
  <pre><code>//COMMAND INITIALISATION
   std::vector&lt;std::string&gt; objectInitialisationAction;
   objectInitialisationAction.push_back("CREATE");              //0
   objectInitialisationAction.push_back("END_CREATE");          //1       
   objectInitialisationAction.push_back("START_TIMELINE");      //2
  </code></pre>
  
  <p>I only access this vector by using my function shown below:</p>
  
  <pre><code>int SearchFor(std::string search, std::vector&lt;std::string&gt; from)
  {
  int result=-1;
  for(int i=0; i&lt;from.size(); i++)
  if(from[i]==search)
  {
       result=i;
       break;
  }
  if(result == -1)
  {
     std::ofstream error("searching.txt");
     error&lt;&lt;"search failed, original value = \""&lt;&lt;search&lt;&lt;"\""&lt;&lt;std::endl;
     error&lt;&lt;"values in the table:"&lt;&lt;std::endl;
     for(int i=0; i&lt;from.size();i++)
     error&lt;&lt;"value "&lt;&lt;i&lt;&lt;": "&lt;&lt;from[i]&lt;&lt;std::endl;
     error.close();
  }
  
  return result;
  }
  </code></pre>
  
  <p>With only one function call:</p>
  
  <pre><code>commandNum=SearchFor(command[0], objectInitialisationAction);
  </code></pre>
  
  <p>This is the only place where I access the vector, yet when I call the function for the nth time (it always brakes at the same point in the code) it accesses wrong and outputs gibberish. Some of the code I list below:</p>
  
  <pre><code>    search failed, original value = "CREATE"
      values in the table:
      value 0: CREATE      Øç¼   Œ                      Ôç¼   Œ                      Ðç¼              Exit               ¼ç¼          ¸ç¼   Œ      p«üxðù   ;    ´ç¼   Œ      pëù@òø  €&lt;    °ç¼   ŒBerlin Sans FB Demi e   ¬ç¼   ˆ°¿^nmra     œç¼   ŒBerlin Sans FB Demi e   ˜ç¼             help        ”ç¼   ˆ          object_dump ç¼             test        Œç¼   Ž          spawn       ˆç¼   ‹          load_map    „ç¼   Ž
  //and so on...   
  </code></pre>
  
  <p>Any suggestions as to why a vector may corrupt like that?</p>