Conversion Functions Like atoi()/atof()

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

Press + to interact
#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 1400+ tech skills courses.