Inplace conversion of partial strings to numeric data

I know how to use the basic strtod, strtol, etc functions and have seen the use of stringstream but what I want is the ability to covert the middle N characters from a string or const char* to a number (int32, uint32, int64, double, float, etc). Does anyone know of any conversion routines out there that will let me do that? Thanks.


1
2
3
4
5
6
std::string text; // number is in this string
size_t pos; // position in string
size_t len; // length of substring
double d;
std::istringstream iss(std::string(text, pos, len));
iss >> d;
Last edited on
Topic archived. No new replies allowed.