Example 1 — Basic stol()
Convert to long.
#include <iostream>
#include <string>
int main() {
long n = std::stol("12345");
std::cout << n << '\\n';
return 0;
} How It Works
- Digits are parsed as base 10.
- Result type is long.
- Printed as 12345.

