title: Find substring between two indices in C++
body: <p>I want to find the substring between two indices. The <a href="http://www.cplusplus.com/reference/string/string/substr/" rel="noreferrer">substr</a>(start_index, number_of_characters) function in C++ returns substring based on number of characters. Hence a small hack to use it with start and end indices is as follows:</p>
  
  <pre><code> // extract 'go' from 'iamgoodhere'
   string s = "iamgoodhere";
   int start = 3, end = 4;
   cout&lt;&lt;s.substr(start,end-start+1); // go
  </code></pre>
  
  <p>What other methods exist in C++ to get the substring between two indices? </p>