Check for errors:
#include <cerrno>
#include <cstdlib>
#include <iostream>
const char str[] = "634.232";
int main()
{
char * e;
errno = 0;
long double val = std::strtold(str, &e);
if (*e != '\0' || errno != 0) { /* error */ std::abort(); }
std::cout << "SUccessfully parsed: " << val;
}
Note that string parsing can fail in multiple ways: The string may not, or not in its entirety, represent a number, or the number that it does represent may be too large to fit into the data type. You have to check for all those possibilities, which is what this code is doing. The end pointer e
checks that we've consumed the entire string, and the errno
checks that the conversion succeeded.