How to convert string to long in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;

int main()
{
	std::string s = "76540310";

	std::string::size_type sz;  

	long l = std::stol(s, &sz);

	cout << l << endl;

	return 0;
}

/*
run:

76540310

*/

 



answered May 23, 2018 by avibootz

Related questions

2 answers 223 views
1 answer 80 views
1 answer 160 views
1 answer 65 views
1 answer 133 views
1 answer 254 views
...