title: Finding Index in string C++
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;string&gt;
  using namespace std;
  
  int contain(vector&lt;string&gt; &amp;s_vector, string check)
      {
      cout&lt;&lt;"Input a string to check: ";
      cin&gt;&gt;check;
      if(s_vector=check) 
       return find(&amp;s_vector);
      else
      return -1;
      }
  
  int main(){
      vector&lt;string&gt;s_vector;
  
      cout&lt;&lt;"Input the size of string vector: ";
      int size;
      cin&gt;&gt;size;
  
      cout&lt;&lt;"Input "&lt;&lt;size&lt;&lt;"strings: \n"; 
      cin&gt;&gt;s_vector[size];
  
      cout&lt;&lt;"Strings in the string vector: ";
      for(int i=0; i&lt;s_vector.size(); i++)
      cout&lt;&lt;s_vector[i]&lt;&lt;" ";
  
      contain(s_vector, string check);
  
      return 0;
  } 
  </code></pre>
  
  <p>I'm trying to make a code where you can find the index of a string. For example the output would be like:</p>
  
  <pre><code>Input the size of string vector: 3
  Input 3 strings:
  asd
  lkj
  qere
  Input a string to check: lkj
  1
  </code></pre>
  
  <p>But there seems to be some errors in the int contain~section, and if I take out the int contain~ section and run the program, it keeps saying "the run has stopped"whenever I try to input the strings. I'm new to C++ so I could really use your help thanks.</p>