Conversion Functions Like atoi()/atof()

This lesson explains why conversion using atof() is not possible with string_view.

#include <iostream>
using namespace std;
int main() {
std::string number = "123.456";
std::string_view svNum { number.data(), 3 };
auto f = atof(svNum.data()); // should be 123, but is 123.456!
std::cout << f << '\n';
}

Get hands-on with 1200+ tech skills courses.