Example 1 — Basic stof()
Convert a decimal string.
#include <iostream>
#include <string>
int main() {
float f = std::stof("3.5");
std::cout << f << '\\n';
return 0;
} How It Works
- Text represents a decimal.
- stof yields a float.
- Printed approximately 3.5.

