title: How would I separate a std::string with more than 1 character I'm looking for?
body: <p>I'm writing a program that can take in multiple names separated by a space, like <code>&quot;John Paul Andrew&quot;</code> and turns the names into keys for a std::map.</p>
  <p>It works fine with two names, but three names or more separate the string into:</p>
  <pre><code>Andrew
  John
  John Paul
  </code></pre>
  <p>Here's how I'm splitting the strings:</p>
  <pre><code>for (int i = 0; i &lt; names.size() - 1; i++) {
          std::string::size_type pos = names.find(&quot; &quot;, i);
  
          std::cout &lt;&lt; &quot;Position of space: &quot; &lt;&lt; pos &lt;&lt; std::endl; // For debugging
  
          if (pos != std::string::npos) {
              std::string name = names.substr(0, pos);
              scoreboard[name] = 0;
          } else {
              std::string name = names.substr(names.rfind(&quot; &quot;) + 1);
              scoreboard[name] = 0;
          }
  
  }
  </code></pre>
  <p>Is there a replacement for <code>names.substr(0, pos);</code> I can use to fix the issue?</p>