title: Finding all occurrences of a character in a string
body: <p>I have comma delimited strings I need to pull values from. The problem is these strings will never be a fixed size. So I decided to iterate through the groups of commas and read what is in between. In order to do that I made a function that returns every occurrence's position in a sample string. </p>
  
  <p>Is this a smart way to do it? Is this considered bad code?</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;Windows.h&gt;
  
  using namespace std;
  
  vector&lt;int&gt; findLocation(string sample, char findIt);
  
  int main()
  {
      string test = "19,,112456.0,a,34656";
      char findIt = ',';
  
      vector&lt;int&gt; results = findLocation(test,findIt);
      return 0;
  }
  
  vector&lt;int&gt; findLocation(string sample, char findIt)
  {
      vector&lt;int&gt; characterLocations;
      for(int i =0; i &lt; sample.size(); i++)
          if(sample[i] == findIt)
              characterLocations.push_back(sample[i]);
  
      return characterLocations;
  }
  </code></pre>