Answers for "string to long c++"

C++
0

string to long c++

//stol(string , nullptr,  base);

string str = "100";
long int num = stol(str, nullptr,  10);
cout << num << std;//output 100

//Base goes over ten with letters:
string str = "F";
long int num = stol(str, nullptr,  16);
cout << num << std;//output 15
Posted by: Guest on September-21-2021

Browse Popular Code Answers by Language