Check out example codes for "string to number in c++". It will help you in understanding the concepts better.

Code Example 1

#include <sstream>

int i = 123;
std::string out_string;
std::stringstream ss;
ss << i;
out_string = ss.str();

Code Example 2

// For C++11 and later versions
string str1 = "45"; 
string str2 = "3.14159"; 
string str3 = "31337 geek"; 

int myint1 = stoi(str1); 
int myint2 = stoi(str2); 
int myint3 = stoi(str3); 

// Output
stoi("45") is 45
stoi("3.14159") is 3
stoi("31337 geek") is 31337

Learn ReactJs, React Native from akashmittal.com