title: Split the string on dot and retrieve each values from it in C++
body: <p>I need to split the string on <code>.</code> in C++..</p>
  
  <p>Below is my string - </p>
  
  <p><code>@event.hello.dc1</code></p>
  
  <p>Now I need to split on <code>.</code> on the above string and retrieve the @event from it and then pass <code>@event</code> to the below method - </p>
  
  <p><code>bool upsert(const char* key);</code></p>
  
  <p>Below is the code I have got so far after reading it from <a href="https://stackoverflow.com/questions/236129/how-to-split-a-string-in-c">here</a> - </p>
  
  <pre><code>void splitString() {
  
      string sentence = "@event.hello.dc1";
  
      istringstream iss(sentence);
      copy(istream_iterator&lt;string&gt;(iss), istream_iterator&lt;string&gt;(), ostream_iterator&lt;string&gt;(cout, "\n"));
  }
  </code></pre>
  
  <p>But I am not able to understand how to extract <code>@event</code> by splitting on <code>.</code> using the above method as the above method only works for whitespace... And also how to extract everything from that string by splitting on <code>.</code> as mentioned like below - </p>
  
  <pre><code>split1 = @event
  split2 = hello
  split3 = dc1
  </code></pre>
  
  <p>Thanks for the help..</p>