title: must use c_str for strchr in C++?
body: <p>I have a need to parse an <code>std::string</code> in c++ <code>std::string s = "my_prefix,my_body,my_suffix";</code></p>
  
  <p>I need only the <code>prefix, suffix</code>. In C (with a similar <code>char*</code> as input) I would have done something like:</p>
  
  <pre><code>char *s = "my_prefix,my_body,my_suffix";
  size_t N = strlen("my_prefix"); // This is actually a fixed length in my real case
  char* suffix = 1 + strrchr(s, ',');
  char* prefix[128];
  snprintf(prefix, N+1, "%s", s);
  printf("prefix = %s\n"  "suffix = %s\n", prefix, suffix);
  </code></pre>
  
  <p>I wanted to use <code>strchr</code> in C++, but from what I see, the <a href="http://www.cplusplus.com/reference/cstring/strchr/" rel="nofollow noreferrer">implementation</a> is only for <code>char*</code>. Must I use <code>c_str()</code> on my string, or is there another way (e.g. a C++ function [not boost and such... I'm using a very lean C++])?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is my try in C++, would that be a good alternative?</p>
  
  <pre><code>std::string s = "my_prefix,my_body,my_suffix";
  char delimiter = ',';
  std::string pre = s.substr(0, s.find_first_of(delimiter));
  std::string suf = s.substr(1 + s.find_last_of (delimiter));
  
  std::cout &lt;&lt; pre &lt;&lt; std::endl;
  std::cout &lt;&lt; suf &lt;&lt; std::endl;
  </code></pre>