I have a string containing "0xAp-2". I want to convert that to a double value:
#include <iostream>
#include <cstdio>
int main()
{
char array[] = "0xAp-2";
double a;
sscanf(array, "%lf", &a);
std::cout << a << "\n";
}
I've tried both atof and sscanf, and can't get it to work. I apologize if the answer is obvious, but I've already tried searching google with terms such as "sscanf" and "floating hexadecimal".
I believe the strtod
function should be able to parse binary scientific notation.