title: C++ Split decimal string into two integers
body: <p>Given a decimal values (seconds and fractions thereof) as a string such as </p>
  
  <pre><code>std::string span = "ssss.nnnn"  // ssss is value in seconds, nnnn is fractional seconds
  </code></pre>
  
  <p>What is the best way to convert it to a timeval structure (val.ts_sec and val.ts_usec) or a timespec structure (tv_sec and tv_nsec).</p>
  
  <p>Most of the answers discuss converting values or are not C++. Some answers get very complex or set up classes which really is too much for this usage.</p>
  
  <p>Obviously sscanf or istringstream can be used if the two values are separated by white space. However, is there a simple way of doing this if they are separated by a "." without looping over the character buffer searching for the "."</p>