Originally Posted by
Sebastiani
When you say "string" I assume you mean std::string, in which case the cast doesn't make sense (use string::data() and drop the cast). Or perhaps you meant char*? In that case, you still don't need the cast. Anyway, since you're (presumably) using C++, there's really no need for unsafe functions like XXXprintf anyway - stringstreams, iostreams, and the like are much safer and also much more flexible as well.
Ok, so assuming you *really* don't need to verify the data (eg: that it is in fact a float, will always have at least two digits after the decimal, etc) an easy way to do it is:
1) Place the data into an std::string
2) Get the position ('pos') of the decimal point with std::string::find
3) Pass 'pos' to std::string::erase
4) Increment 'pos'
5) Pass 'pos' to std::string::resize