Given a decimal values (seconds and fractions thereof) as a string such as
std::string span = "ssss.nnnn" // ssss is value in seconds, nnnn is fractional seconds
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).
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.
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 "."